aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/Application.cs250
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs992
-rw-r--r--OpenSim/Region/Application/VersionInfo.cs72
-rw-r--r--OpenSim/Region/Caches/AssetCache.cs1338
-rw-r--r--OpenSim/Region/Caches/Properties/AssemblyInfo.cs66
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs626
-rw-r--r--OpenSim/Region/Capabilities/LLSDArray.cs84
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs88
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs42
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs36
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapEvent.cs82
-rw-r--r--OpenSim/Region/Capabilities/LLSDCapsDetails.cs34
-rw-r--r--OpenSim/Region/Capabilities/LLSDEmpty.cs76
-rw-r--r--OpenSim/Region/Capabilities/LLSDHelpers.cs328
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayer.cs92
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs82
-rw-r--r--OpenSim/Region/Capabilities/LLSDMapRequest.cs26
-rw-r--r--OpenSim/Region/Capabilities/LLSDMethod.cs16
-rw-r--r--OpenSim/Region/Capabilities/LLSDStreamHandler.cs84
-rw-r--r--OpenSim/Region/Capabilities/LLSDTest.cs82
-rw-r--r--OpenSim/Region/Capabilities/LLSDType.cs118
-rw-r--r--OpenSim/Region/ClientStack/Assets/InventoryCache.cs676
-rw-r--r--OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs80
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs2360
-rw-r--r--OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs714
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs472
-rw-r--r--OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs1294
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs586
-rw-r--r--OpenSim/Region/ClientStack/ClientViewBase.cs652
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs368
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs236
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs390
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs110
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs412
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs284
-rw-r--r--OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs66
-rw-r--r--OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs36
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs862
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs138
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs202
-rw-r--r--OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs66
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs598
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs124
-rw-r--r--OpenSim/Region/Environment/ParcelManager.cs2412
-rw-r--r--OpenSim/Region/Environment/RegionManager.cs58
-rw-r--r--OpenSim/Region/Environment/Scenes/Entity.cs230
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityBase.cs284
-rw-r--r--OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs28
-rw-r--r--OpenSim/Region/Environment/Scenes/Primitive.cs1296
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs1236
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs1838
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs390
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs164
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs618
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs148
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs170
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs1246
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs204
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs138
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs204
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs90
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs1006
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs86
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs854
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs192
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs80
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs270
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs90
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs92
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs74
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs84
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs98
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs238
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs58
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs340
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs20
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs20
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs32
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs20
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs20
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs32
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs32
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs280
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs102
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs970
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs1216
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs210
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/Script.cs128
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs64
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs116
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs412
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs32
-rw-r--r--OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs214
-rw-r--r--OpenSim/Region/Environment/StorageManager.cs120
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs368
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MySceneObject.cs80
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs194
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs252
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs62
-rw-r--r--OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs622
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs266
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs602
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs1068
-rw-r--r--OpenSim/Region/Physics/Manager/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs334
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsManager.cs230
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs220
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs110
-rw-r--r--OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs914
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs850
-rw-r--r--OpenSim/Region/Scripting/Properties/AssemblyInfo.cs70
-rw-r--r--OpenSim/Region/Scripting/Script.cs64
-rw-r--r--OpenSim/Region/Scripting/ScriptAccess.cs62
-rw-r--r--OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs222
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs532
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs76
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs94
-rw-r--r--OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs94
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs120
-rw-r--r--OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs394
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs131
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs70
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs120
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs1906
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs252
132 files changed, 22486 insertions, 22485 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index 10beaff..666be33 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -1,125 +1,125 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using OpenSim.Framework.Console; 29using OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
31 31
32namespace OpenSim 32namespace OpenSim
33{ 33{
34 public class Application 34 public class Application
35 { 35 {
36 //could move our main function into OpenSimMain and kill this class 36 //could move our main function into OpenSimMain and kill this class
37 [STAThread] 37 [STAThread]
38 public static void Main(string[] args) 38 public static void Main(string[] args)
39 { 39 {
40 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); 40 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
41 Console.WriteLine("Starting...\n"); 41 Console.WriteLine("Starting...\n");
42 42
43 bool sandBoxMode = false; 43 bool sandBoxMode = false;
44 bool startLoginServer = false; 44 bool startLoginServer = false;
45 string physicsEngine = "basicphysics"; 45 string physicsEngine = "basicphysics";
46 bool allowFlying = false; 46 bool allowFlying = false;
47 bool userAccounts = false; 47 bool userAccounts = false;
48 bool gridLocalAsset = false; 48 bool gridLocalAsset = false;
49 bool useConfigFile = false; 49 bool useConfigFile = false;
50 bool silent = false; 50 bool silent = false;
51 string configFile = "simconfig.xml"; 51 string configFile = "simconfig.xml";
52 52
53 for (int i = 0; i < args.Length; i++) 53 for (int i = 0; i < args.Length; i++)
54 { 54 {
55 if (args[i] == "-sandbox") 55 if (args[i] == "-sandbox")
56 { 56 {
57 sandBoxMode = true; 57 sandBoxMode = true;
58 startLoginServer = true; 58 startLoginServer = true;
59 } 59 }
60 /* 60 /*
61 if (args[i] == "-loginserver") 61 if (args[i] == "-loginserver")
62 { 62 {
63 startLoginServer = true; 63 startLoginServer = true;
64 }*/ 64 }*/
65 if (args[i] == "-accounts") 65 if (args[i] == "-accounts")
66 { 66 {
67 userAccounts = true; 67 userAccounts = true;
68 } 68 }
69 if (args[i] == "-realphysx") 69 if (args[i] == "-realphysx")
70 { 70 {
71 physicsEngine = "RealPhysX"; 71 physicsEngine = "RealPhysX";
72 allowFlying = true; 72 allowFlying = true;
73 } 73 }
74 if (args[i] == "-bulletX") 74 if (args[i] == "-bulletX")
75 { 75 {
76 physicsEngine = "BulletXEngine"; 76 physicsEngine = "BulletXEngine";
77 allowFlying = true; 77 allowFlying = true;
78 } 78 }
79 if (args[i] == "-ode") 79 if (args[i] == "-ode")
80 { 80 {
81 physicsEngine = "OpenDynamicsEngine"; 81 physicsEngine = "OpenDynamicsEngine";
82 allowFlying = true; 82 allowFlying = true;
83 } 83 }
84 if (args[i] == "-localasset") 84 if (args[i] == "-localasset")
85 { 85 {
86 gridLocalAsset = true; 86 gridLocalAsset = true;
87 } 87 }
88 if (args[i] == "-configfile") 88 if (args[i] == "-configfile")
89 { 89 {
90 useConfigFile = true; 90 useConfigFile = true;
91 } 91 }
92 if (args[i] == "-noverbose") 92 if (args[i] == "-noverbose")
93 { 93 {
94 silent = true; 94 silent = true;
95 } 95 }
96 if (args[i] == "-config") 96 if (args[i] == "-config")
97 { 97 {
98 try 98 try
99 { 99 {
100 i++; 100 i++;
101 configFile = args[i]; 101 configFile = args[i];
102 } 102 }
103 catch (Exception e) 103 catch (Exception e)
104 { 104 {
105 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")"); 105 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile); 110 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
111 // OpenSimRoot.Instance.Application = sim; 111 // OpenSimRoot.Instance.Application = sim;
112 sim.m_sandbox = sandBoxMode; 112 sim.m_sandbox = sandBoxMode;
113 sim.user_accounts = userAccounts; 113 sim.user_accounts = userAccounts;
114 sim.gridLocalAsset = gridLocalAsset; 114 sim.gridLocalAsset = gridLocalAsset;
115 ScenePresence.PhysicsEngineFlying = allowFlying; 115 ScenePresence.PhysicsEngineFlying = allowFlying;
116 116
117 sim.StartUp(); 117 sim.StartUp();
118 118
119 while (true) 119 while (true)
120 { 120 {
121 MainLog.Instance.MainLogPrompt(); 121 MainLog.Instance.MainLogPrompt();
122 } 122 }
123 } 123 }
124 } 124 }
125} 125}
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 99164f1..08d7619 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -1,496 +1,496 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.IO; 30using System.IO;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Assets; 32using OpenSim.Assets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Data; 36using OpenSim.Framework.Data;
37using OpenSim.Framework.Interfaces; 37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types; 39using OpenSim.Framework.Types;
40using OpenSim.GenericConfig; 40using OpenSim.GenericConfig;
41using OpenSim.Physics.Manager; 41using OpenSim.Physics.Manager;
42using OpenSim.Region.Caches; 42using OpenSim.Region.Caches;
43using OpenSim.Region.ClientStack; 43using OpenSim.Region.ClientStack;
44using OpenSim.Region.Communications.Local; 44using OpenSim.Region.Communications.Local;
45using OpenSim.Region.Communications.OGS1; 45using OpenSim.Region.Communications.OGS1;
46using OpenSim.Region.Environment.Scenes; 46using OpenSim.Region.Environment.Scenes;
47using OpenSim.Region.Environment; 47using OpenSim.Region.Environment;
48using System.Text; 48using System.Text;
49 49
50namespace OpenSim 50namespace OpenSim
51{ 51{
52 52
53 public class OpenSimMain : RegionApplicationBase, conscmd_callback 53 public class OpenSimMain : RegionApplicationBase, conscmd_callback
54 { 54 {
55 protected CommunicationsManager commsManager; 55 protected CommunicationsManager commsManager;
56 // private CheckSumServer checkServer; 56 // private CheckSumServer checkServer;
57 57
58 private bool m_silent; 58 private bool m_silent;
59 private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log"; 59 private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
60 60
61 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) 61 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
62 { 62 {
63 this.configFileSetup = useConfigFile; 63 this.configFileSetup = useConfigFile;
64 m_sandbox = sandBoxMode; 64 m_sandbox = sandBoxMode;
65 m_loginserver = startLoginServer; 65 m_loginserver = startLoginServer;
66 m_physicsEngine = physicsEngine; 66 m_physicsEngine = physicsEngine;
67 m_config = configFile; 67 m_config = configFile;
68 m_silent = silent; 68 m_silent = silent;
69 } 69 }
70 70
71 /// <summary> 71 /// <summary>
72 /// Performs initialisation of the world, such as loading configuration from disk. 72 /// Performs initialisation of the world, such as loading configuration from disk.
73 /// </summary> 73 /// </summary>
74 public override void StartUp() 74 public override void StartUp()
75 { 75 {
76 this.serversData = new NetworkServersInfo(); 76 this.serversData = new NetworkServersInfo();
77 77
78 this.localConfig = new XmlConfig(m_config); 78 this.localConfig = new XmlConfig(m_config);
79 this.localConfig.LoadData(); 79 this.localConfig.LoadData();
80 80
81 if (this.configFileSetup) 81 if (this.configFileSetup)
82 { 82 {
83 this.SetupFromConfigFile(this.localConfig); 83 this.SetupFromConfigFile(this.localConfig);
84 } 84 }
85 85
86 m_log = new LogBase(m_logFilename, "Region", this, m_silent); 86 m_log = new LogBase(m_logFilename, "Region", this, m_silent);
87 MainLog.Instance = m_log; 87 MainLog.Instance = m_log;
88 88
89 m_log.Verbose("Main.cs:Startup() - Loading configuration"); 89 m_log.Verbose("Main.cs:Startup() - Loading configuration");
90 this.serversData.InitConfig(this.m_sandbox, this.localConfig); 90 this.serversData.InitConfig(this.m_sandbox, this.localConfig);
91 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change 91 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
92 92
93 ScenePresence.LoadTextureFile("avatar-texture.dat"); 93 ScenePresence.LoadTextureFile("avatar-texture.dat");
94 94
95 ClientView.TerrainManager = new TerrainManager(new SecondLife()); 95 ClientView.TerrainManager = new TerrainManager(new SecondLife());
96 96
97 this.SetupHttpListener(); 97 this.SetupHttpListener();
98 98
99 if (m_sandbox) 99 if (m_sandbox)
100 { 100 {
101 this.SetupLocalGridServers(); 101 this.SetupLocalGridServers();
102 // this.checkServer = new CheckSumServer(12036); 102 // this.checkServer = new CheckSumServer(12036);
103 // this.checkServer.ServerListener(); 103 // this.checkServer.ServerListener();
104 } 104 }
105 else 105 else
106 { 106 {
107 this.SetupRemoteGridServers(); 107 this.SetupRemoteGridServers();
108 } 108 }
109 109
110 startuptime = DateTime.Now; 110 startuptime = DateTime.Now;
111 111
112 this.physManager = new PhysicsManager(); 112 this.physManager = new PhysicsManager();
113 this.physManager.LoadPlugins(); 113 this.physManager.LoadPlugins();
114 114
115 this.SetupScene(); 115 this.SetupScene();
116 116
117 m_log.Verbose("Main.cs:Startup() - Initialising HTTP server"); 117 m_log.Verbose("Main.cs:Startup() - Initialising HTTP server");
118 118
119 //Start http server 119 //Start http server
120 m_log.Verbose("Main.cs:Startup() - Starting HTTP server"); 120 m_log.Verbose("Main.cs:Startup() - Starting HTTP server");
121 httpServer.Start(); 121 httpServer.Start();
122 122
123 // Start UDP servers 123 // Start UDP servers
124 for (int i = 0; i < m_udpServer.Count; i++) 124 for (int i = 0; i < m_udpServer.Count; i++)
125 { 125 {
126 this.m_udpServer[i].ServerListener(); 126 this.m_udpServer[i].ServerListener();
127 } 127 }
128 128
129 } 129 }
130 130
131 # region Setup methods 131 # region Setup methods
132 protected override void SetupLocalGridServers() 132 protected override void SetupLocalGridServers()
133 { 133 {
134 try 134 try
135 { 135 {
136 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey); 136 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
137 InventoryCache = new InventoryCache(); 137 InventoryCache = new InventoryCache();
138 this.commsManager = new CommunicationsLocal(this.serversData, httpServer); 138 this.commsManager = new CommunicationsLocal(this.serversData, httpServer);
139 } 139 }
140 catch (Exception e) 140 catch (Exception e)
141 { 141 {
142 m_log.Error(e.Message + "\nSorry, could not setup local cache"); 142 m_log.Error(e.Message + "\nSorry, could not setup local cache");
143 Environment.Exit(1); 143 Environment.Exit(1);
144 } 144 }
145 145
146 } 146 }
147 147
148 protected override void SetupRemoteGridServers() 148 protected override void SetupRemoteGridServers()
149 { 149 {
150 try 150 try
151 { 151 {
152 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey); 152 AssetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
153 InventoryCache = new InventoryCache(); 153 InventoryCache = new InventoryCache();
154 this.commsManager = new CommunicationsOGS1(this.serversData, httpServer); 154 this.commsManager = new CommunicationsOGS1(this.serversData, httpServer);
155 } 155 }
156 catch (Exception e) 156 catch (Exception e)
157 { 157 {
158 m_log.Error(e.Message + "\nSorry, could not setup remote cache"); 158 m_log.Error(e.Message + "\nSorry, could not setup remote cache");
159 Environment.Exit(1); 159 Environment.Exit(1);
160 } 160 }
161 } 161 }
162 162
163 protected override void SetupScene() 163 protected override void SetupScene()
164 { 164 {
165 IGenericConfig regionConfig; 165 IGenericConfig regionConfig;
166 Scene scene; 166 Scene scene;
167 UDPServer udpServer; 167 UDPServer udpServer;
168 RegionInfo regionDat = new RegionInfo(); 168 RegionInfo regionDat = new RegionInfo();
169 AuthenticateSessionsBase authenBase; 169 AuthenticateSessionsBase authenBase;
170 170
171 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); 171 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
172 string[] configFiles = Directory.GetFiles(path, "*.xml"); 172 string[] configFiles = Directory.GetFiles(path, "*.xml");
173 173
174 if (configFiles.Length == 0) 174 if (configFiles.Length == 0)
175 { 175 {
176 string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); 176 string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
177 string path3 = Path.Combine(path2, "default.xml"); 177 string path3 = Path.Combine(path2, "default.xml");
178 Console.WriteLine("Creating default region config file"); 178 Console.WriteLine("Creating default region config file");
179 //TODO create default region 179 //TODO create default region
180 IGenericConfig defaultConfig = new XmlConfig(path3); 180 IGenericConfig defaultConfig = new XmlConfig(path3);
181 defaultConfig.LoadData(); 181 defaultConfig.LoadData();
182 defaultConfig.Commit(); 182 defaultConfig.Commit();
183 defaultConfig.Close(); 183 defaultConfig.Close();
184 defaultConfig = null; 184 defaultConfig = null;
185 configFiles = Directory.GetFiles(path, "*.xml"); 185 configFiles = Directory.GetFiles(path, "*.xml");
186 } 186 }
187 187
188 for (int i = 0; i < configFiles.Length; i++) 188 for (int i = 0; i < configFiles.Length; i++)
189 { 189 {
190 regionDat = new RegionInfo(); 190 regionDat = new RegionInfo();
191 if (m_sandbox) 191 if (m_sandbox)
192 { 192 {
193 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); 193 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
194 this.AuthenticateSessionsHandler.Add(authen); 194 this.AuthenticateSessionsHandler.Add(authen);
195 authenBase = authen; 195 authenBase = authen;
196 } 196 }
197 else 197 else
198 { 198 {
199 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote(); 199 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote();
200 this.AuthenticateSessionsHandler.Add(authen); 200 this.AuthenticateSessionsHandler.Add(authen);
201 authenBase = authen; 201 authenBase = authen;
202 } 202 }
203 Console.WriteLine("Loading region config file"); 203 Console.WriteLine("Loading region config file");
204 regionConfig = new XmlConfig(configFiles[i]); 204 regionConfig = new XmlConfig(configFiles[i]);
205 regionConfig.LoadData(); 205 regionConfig.LoadData();
206 regionDat.InitConfig(this.m_sandbox, regionConfig); 206 regionDat.InitConfig(this.m_sandbox, regionConfig);
207 regionConfig.Close(); 207 regionConfig.Close();
208 208
209 udpServer = new UDPServer(regionDat.InternalEndPoint.Port, this.AssetCache, this.InventoryCache, this.m_log, authenBase); 209 udpServer = new UDPServer(regionDat.InternalEndPoint.Port, this.AssetCache, this.InventoryCache, this.m_log, authenBase);
210 210
211 m_udpServer.Add(udpServer); 211 m_udpServer.Add(udpServer);
212 this.regionData.Add(regionDat); 212 this.regionData.Add(regionDat);
213 213
214 StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", regionDat.DataStore, regionDat.RegionName); 214 StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", regionDat.DataStore, regionDat.RegionName);
215 215
216 scene = new Scene( regionDat, authenBase, commsManager, this.AssetCache, tmpStoreManager, httpServer); 216 scene = new Scene( regionDat, authenBase, commsManager, this.AssetCache, tmpStoreManager, httpServer);
217 this.m_localWorld.Add(scene); 217 this.m_localWorld.Add(scene);
218 218
219 udpServer.LocalWorld = scene; 219 udpServer.LocalWorld = scene;
220 220
221 scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. 221 scene.LoadStorageDLL("OpenSim.Region.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
222 scene.LoadWorldMap(); 222 scene.LoadWorldMap();
223 223
224 m_log.Verbose("Main.cs:Startup() - Starting up messaging system"); 224 m_log.Verbose("Main.cs:Startup() - Starting up messaging system");
225 scene.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); 225 scene.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
226 scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); 226 scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D());
227 scene.LoadPrimsFromStorage(); 227 scene.LoadPrimsFromStorage();
228 228
229 //Master Avatar Setup 229 //Master Avatar Setup
230 UserProfileData masterAvatar = commsManager.UserServer.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword); 230 UserProfileData masterAvatar = commsManager.UserServer.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword);
231 if (masterAvatar != null) 231 if (masterAvatar != null)
232 { 232 {
233 m_log.Notice("Parcels - Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); 233 m_log.Notice("Parcels - Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]");
234 scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; 234 scene.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
235 scene.localStorage.LoadParcels((ILocalStorageParcelReceiver)scene.ParcelManager); 235 scene.localStorage.LoadParcels((ILocalStorageParcelReceiver)scene.ParcelManager);
236 } 236 }
237 else 237 else
238 { 238 {
239 m_log.Notice("Parcels - No master avatar found, using null."); 239 m_log.Notice("Parcels - No master avatar found, using null.");
240 scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; 240 scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero;
241 scene.localStorage.LoadParcels((ILocalStorageParcelReceiver)scene.ParcelManager); 241 scene.localStorage.LoadParcels((ILocalStorageParcelReceiver)scene.ParcelManager);
242 } 242 }
243 scene.performParcelPrimCountUpdate(); 243 scene.performParcelPrimCountUpdate();
244 scene.StartTimer(); 244 scene.StartTimer();
245 } 245 }
246 } 246 }
247 247
248 private class SimStatusHandler : IStreamHandler 248 private class SimStatusHandler : IStreamHandler
249 { 249 {
250 public byte[] Handle(string path, Stream request) 250 public byte[] Handle(string path, Stream request)
251 { 251 {
252 return Encoding.UTF8.GetBytes("OK"); 252 return Encoding.UTF8.GetBytes("OK");
253 } 253 }
254 254
255 public string ContentType 255 public string ContentType
256 { 256 {
257 get { return "text/plain"; } 257 get { return "text/plain"; }
258 } 258 }
259 259
260 public string HttpMethod 260 public string HttpMethod
261 { 261 {
262 get { return "GET"; } 262 get { return "GET"; }
263 } 263 }
264 264
265 public string Path 265 public string Path
266 { 266 {
267 get { return "/simstatus/"; } 267 get { return "/simstatus/"; }
268 } 268 }
269 } 269 }
270 270
271 protected override void SetupHttpListener() 271 protected override void SetupHttpListener()
272 { 272 {
273 httpServer = new BaseHttpServer(this.serversData.HttpListenerPort); //regionData[0].IPListenPort); 273 httpServer = new BaseHttpServer(this.serversData.HttpListenerPort); //regionData[0].IPListenPort);
274 274
275 if (!this.m_sandbox) 275 if (!this.m_sandbox)
276 { 276 {
277 httpServer.AddStreamHandler( new SimStatusHandler() ); 277 httpServer.AddStreamHandler( new SimStatusHandler() );
278 } 278 }
279 } 279 }
280 280
281 protected override void ConnectToRemoteGridServer() 281 protected override void ConnectToRemoteGridServer()
282 { 282 {
283 283
284 } 284 }
285 285
286 #endregion 286 #endregion
287 287
288 private void SetupFromConfigFile(IGenericConfig configData) 288 private void SetupFromConfigFile(IGenericConfig configData)
289 { 289 {
290 // Log filename 290 // Log filename
291 string attri = ""; 291 string attri = "";
292 attri = configData.GetAttribute("LogFilename"); 292 attri = configData.GetAttribute("LogFilename");
293 if (String.IsNullOrEmpty(attri)) 293 if (String.IsNullOrEmpty(attri))
294 { 294 {
295 } 295 }
296 else 296 else
297 { 297 {
298 m_logFilename = attri; 298 m_logFilename = attri;
299 } 299 }
300 300
301 // SandBoxMode 301 // SandBoxMode
302 attri = ""; 302 attri = "";
303 attri = configData.GetAttribute("SandBox"); 303 attri = configData.GetAttribute("SandBox");
304 if ((attri == "") || ((attri != "false") && (attri != "true"))) 304 if ((attri == "") || ((attri != "false") && (attri != "true")))
305 { 305 {
306 this.m_sandbox = false; 306 this.m_sandbox = false;
307 configData.SetAttribute("SandBox", "false"); 307 configData.SetAttribute("SandBox", "false");
308 } 308 }
309 else 309 else
310 { 310 {
311 this.m_sandbox = Convert.ToBoolean(attri); 311 this.m_sandbox = Convert.ToBoolean(attri);
312 } 312 }
313 313
314 // LoginServer 314 // LoginServer
315 attri = ""; 315 attri = "";
316 attri = configData.GetAttribute("LoginServer"); 316 attri = configData.GetAttribute("LoginServer");
317 if ((attri == "") || ((attri != "false") && (attri != "true"))) 317 if ((attri == "") || ((attri != "false") && (attri != "true")))
318 { 318 {
319 this.m_loginserver = false; 319 this.m_loginserver = false;
320 configData.SetAttribute("LoginServer", "false"); 320 configData.SetAttribute("LoginServer", "false");
321 } 321 }
322 else 322 else
323 { 323 {
324 this.m_loginserver = Convert.ToBoolean(attri); 324 this.m_loginserver = Convert.ToBoolean(attri);
325 } 325 }
326 326
327 // Sandbox User accounts 327 // Sandbox User accounts
328 attri = ""; 328 attri = "";
329 attri = configData.GetAttribute("UserAccount"); 329 attri = configData.GetAttribute("UserAccount");
330 if ((attri == "") || ((attri != "false") && (attri != "true"))) 330 if ((attri == "") || ((attri != "false") && (attri != "true")))
331 { 331 {
332 this.user_accounts = false; 332 this.user_accounts = false;
333 configData.SetAttribute("UserAccounts", "false"); 333 configData.SetAttribute("UserAccounts", "false");
334 } 334 }
335 else if (attri == "true") 335 else if (attri == "true")
336 { 336 {
337 this.user_accounts = Convert.ToBoolean(attri); 337 this.user_accounts = Convert.ToBoolean(attri);
338 } 338 }
339 339
340 // Grid mode hack to use local asset server 340 // Grid mode hack to use local asset server
341 attri = ""; 341 attri = "";
342 attri = configData.GetAttribute("LocalAssets"); 342 attri = configData.GetAttribute("LocalAssets");
343 if ((attri == "") || ((attri != "false") && (attri != "true"))) 343 if ((attri == "") || ((attri != "false") && (attri != "true")))
344 { 344 {
345 this.gridLocalAsset = false; 345 this.gridLocalAsset = false;
346 configData.SetAttribute("LocalAssets", "false"); 346 configData.SetAttribute("LocalAssets", "false");
347 } 347 }
348 else if (attri == "true") 348 else if (attri == "true")
349 { 349 {
350 this.gridLocalAsset = Convert.ToBoolean(attri); 350 this.gridLocalAsset = Convert.ToBoolean(attri);
351 } 351 }
352 352
353 353
354 attri = ""; 354 attri = "";
355 attri = configData.GetAttribute("PhysicsEngine"); 355 attri = configData.GetAttribute("PhysicsEngine");
356 switch (attri) 356 switch (attri)
357 { 357 {
358 default: 358 default:
359 m_log.Warn("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); 359 m_log.Warn("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
360 Environment.Exit(1); 360 Environment.Exit(1);
361 break; 361 break;
362 362
363 case "": 363 case "":
364 this.m_physicsEngine = "basicphysics"; 364 this.m_physicsEngine = "basicphysics";
365 configData.SetAttribute("PhysicsEngine", "basicphysics"); 365 configData.SetAttribute("PhysicsEngine", "basicphysics");
366 ScenePresence.PhysicsEngineFlying = false; 366 ScenePresence.PhysicsEngineFlying = false;
367 break; 367 break;
368 368
369 case "basicphysics": 369 case "basicphysics":
370 this.m_physicsEngine = "basicphysics"; 370 this.m_physicsEngine = "basicphysics";
371 configData.SetAttribute("PhysicsEngine", "basicphysics"); 371 configData.SetAttribute("PhysicsEngine", "basicphysics");
372 ScenePresence.PhysicsEngineFlying = false; 372 ScenePresence.PhysicsEngineFlying = false;
373 break; 373 break;
374 374
375 case "RealPhysX": 375 case "RealPhysX":
376 this.m_physicsEngine = "RealPhysX"; 376 this.m_physicsEngine = "RealPhysX";
377 ScenePresence.PhysicsEngineFlying = true; 377 ScenePresence.PhysicsEngineFlying = true;
378 break; 378 break;
379 379
380 case "OpenDynamicsEngine": 380 case "OpenDynamicsEngine":
381 this.m_physicsEngine = "OpenDynamicsEngine"; 381 this.m_physicsEngine = "OpenDynamicsEngine";
382 ScenePresence.PhysicsEngineFlying = true; 382 ScenePresence.PhysicsEngineFlying = true;
383 break; 383 break;
384 384
385 case "BulletXEngine": 385 case "BulletXEngine":
386 this.m_physicsEngine = "BulletXEngine"; 386 this.m_physicsEngine = "BulletXEngine";
387 ScenePresence.PhysicsEngineFlying = true; 387 ScenePresence.PhysicsEngineFlying = true;
388 break; 388 break;
389 } 389 }
390 390
391 configData.Commit(); 391 configData.Commit();
392 392
393 } 393 }
394 394
395 /// <summary> 395 /// <summary>
396 /// Performs any last-minute sanity checking and shuts down the region server 396 /// Performs any last-minute sanity checking and shuts down the region server
397 /// </summary> 397 /// </summary>
398 public virtual void Shutdown() 398 public virtual void Shutdown()
399 { 399 {
400 m_log.Verbose("Main.cs:Shutdown() - Closing all threads"); 400 m_log.Verbose("Main.cs:Shutdown() - Closing all threads");
401 m_log.Verbose("Main.cs:Shutdown() - Killing listener thread"); 401 m_log.Verbose("Main.cs:Shutdown() - Killing listener thread");
402 m_log.Verbose("Main.cs:Shutdown() - Killing clients"); 402 m_log.Verbose("Main.cs:Shutdown() - Killing clients");
403 // IMPLEMENT THIS 403 // IMPLEMENT THIS
404 m_log.Verbose("Main.cs:Shutdown() - Closing console and terminating"); 404 m_log.Verbose("Main.cs:Shutdown() - Closing console and terminating");
405 for (int i = 0; i < m_localWorld.Count; i++) 405 for (int i = 0; i < m_localWorld.Count; i++)
406 { 406 {
407 ((Scene)m_localWorld[i]).Close(); 407 ((Scene)m_localWorld[i]).Close();
408 } 408 }
409 m_log.Close(); 409 m_log.Close();
410 Environment.Exit(0); 410 Environment.Exit(0);
411 } 411 }
412 412
413 #region Console Commands 413 #region Console Commands
414 /// <summary> 414 /// <summary>
415 /// Runs commands issued by the server console from the operator 415 /// Runs commands issued by the server console from the operator
416 /// </summary> 416 /// </summary>
417 /// <param name="command">The first argument of the parameter (the command)</param> 417 /// <param name="command">The first argument of the parameter (the command)</param>
418 /// <param name="cmdparams">Additional arguments passed to the command</param> 418 /// <param name="cmdparams">Additional arguments passed to the command</param>
419 public void RunCmd(string command, string[] cmdparams) 419 public void RunCmd(string command, string[] cmdparams)
420 { 420 {
421 switch (command) 421 switch (command)
422 { 422 {
423 case "help": 423 case "help":
424 m_log.Error("show users - show info about connected users"); 424 m_log.Error("show users - show info about connected users");
425 m_log.Error("quit - disconnect all clients and shutdown"); 425 m_log.Error("quit - disconnect all clients and shutdown");
426 break; 426 break;
427 427
428 case "show": 428 case "show":
429 if (cmdparams.Length > 0) 429 if (cmdparams.Length > 0)
430 { 430 {
431 Show(cmdparams[0]); 431 Show(cmdparams[0]);
432 } 432 }
433 break; 433 break;
434 434
435 case "terrain": 435 case "terrain":
436 string result = ""; 436 string result = "";
437 for (int i = 0; i < m_localWorld.Count; i++) 437 for (int i = 0; i < m_localWorld.Count; i++)
438 { 438 {
439 if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result, m_localWorld[i].RegionInfo.RegionName)) 439 if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result, m_localWorld[i].RegionInfo.RegionName))
440 { 440 {
441 m_log.Error(result); 441 m_log.Error(result);
442 } 442 }
443 } 443 }
444 break; 444 break;
445 case "script": 445 case "script":
446 for (int i = 0; i < m_localWorld.Count; i++) 446 for (int i = 0; i < m_localWorld.Count; i++)
447 { 447 {
448 ((Scene)m_localWorld[i]).SendCommandToScripts(cmdparams); 448 ((Scene)m_localWorld[i]).SendCommandToScripts(cmdparams);
449 } 449 }
450 break; 450 break;
451 451
452 case "quit": 452 case "quit":
453 case "shutdown": 453 case "shutdown":
454 Shutdown(); 454 Shutdown();
455 break; 455 break;
456 456
457 default: 457 default:
458 m_log.Error("Unknown command"); 458 m_log.Error("Unknown command");
459 break; 459 break;
460 } 460 }
461 } 461 }
462 462
463 /// <summary> 463 /// <summary>
464 /// Outputs to the console information about the region 464 /// Outputs to the console information about the region
465 /// </summary> 465 /// </summary>
466 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param> 466 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
467 public void Show(string ShowWhat) 467 public void Show(string ShowWhat)
468 { 468 {
469 switch (ShowWhat) 469 switch (ShowWhat)
470 { 470 {
471 case "uptime": 471 case "uptime":
472 m_log.Error("OpenSim has been running since " + startuptime.ToString()); 472 m_log.Error("OpenSim has been running since " + startuptime.ToString());
473 m_log.Error("That is " + (DateTime.Now - startuptime).ToString()); 473 m_log.Error("That is " + (DateTime.Now - startuptime).ToString());
474 break; 474 break;
475 case "users": 475 case "users":
476 ScenePresence TempAv; 476 ScenePresence TempAv;
477 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); 477 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
478 for (int i = 0; i < m_localWorld.Count; i++) 478 for (int i = 0; i < m_localWorld.Count; i++)
479 { 479 {
480 foreach (libsecondlife.LLUUID UUID in ((Scene)m_localWorld[i]).Entities.Keys) 480 foreach (libsecondlife.LLUUID UUID in ((Scene)m_localWorld[i]).Entities.Keys)
481 { 481 {
482 if (((Scene)m_localWorld[i]).Entities[UUID].ToString() == "OpenSim.world.Avatar") 482 if (((Scene)m_localWorld[i]).Entities[UUID].ToString() == "OpenSim.world.Avatar")
483 { 483 {
484 TempAv = (ScenePresence)((Scene)m_localWorld[i]).Entities[UUID]; 484 TempAv = (ScenePresence)((Scene)m_localWorld[i]).Entities[UUID];
485 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.AgentId, "Unknown", "Unknown"), ((Scene)m_localWorld[i]).RegionInfo.RegionName); 485 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.AgentId, "Unknown", "Unknown"), ((Scene)m_localWorld[i]).RegionInfo.RegionName);
486 } 486 }
487 } 487 }
488 } 488 }
489 break; 489 break;
490 } 490 }
491 } 491 }
492 #endregion 492 #endregion
493 } 493 }
494 494
495 495
496} 496}
diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs
index 2c720a3..6952d24 100644
--- a/OpenSim/Region/Application/VersionInfo.cs
+++ b/OpenSim/Region/Application/VersionInfo.cs
@@ -1,36 +1,36 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim 28namespace OpenSim
29{ 29{
30 /// <summary> 30 /// <summary>
31 /// </summary> 31 /// </summary>
32 public class VersionInfo 32 public class VersionInfo
33 { 33 {
34 public static string Version = "0.3, SVN build "; 34 public static string Version = "0.3, SVN build ";
35 } 35 }
36} 36}
diff --git a/OpenSim/Region/Caches/AssetCache.cs b/OpenSim/Region/Caches/AssetCache.cs
index 453edbe..8deb0a1 100644
--- a/OpenSim/Region/Caches/AssetCache.cs
+++ b/OpenSim/Region/Caches/AssetCache.cs
@@ -1,669 +1,669 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.Packets; 34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37 37
38namespace OpenSim.Region.Caches 38namespace OpenSim.Region.Caches
39{ 39{
40 public delegate void DownloadComplete(AssetCache.TextureSender sender); 40 public delegate void DownloadComplete(AssetCache.TextureSender sender);
41 41
42 /// <summary> 42 /// <summary>
43 /// Manages local cache of assets and their sending to viewers. 43 /// Manages local cache of assets and their sending to viewers.
44 /// </summary> 44 /// </summary>
45 public class AssetCache : IAssetReceiver 45 public class AssetCache : IAssetReceiver
46 { 46 {
47 public Dictionary<LLUUID, AssetInfo> Assets; 47 public Dictionary<LLUUID, AssetInfo> Assets;
48 public Dictionary<LLUUID, TextureImage> Textures; 48 public Dictionary<LLUUID, TextureImage> Textures;
49 49
50 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers 50 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
51 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent 51 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
52 52
53 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server 53 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
54 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server 54 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
55 55
56 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>(); 56 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
57 private IAssetServer _assetServer; 57 private IAssetServer _assetServer;
58 private Thread _assetCacheThread; 58 private Thread _assetCacheThread;
59 private LLUUID[] textureList = new LLUUID[5]; 59 private LLUUID[] textureList = new LLUUID[5];
60 60
61 /// <summary> 61 /// <summary>
62 /// 62 ///
63 /// </summary> 63 /// </summary>
64 public AssetCache(IAssetServer assetServer) 64 public AssetCache(IAssetServer assetServer)
65 { 65 {
66 Console.WriteLine("Creating Asset cache"); 66 Console.WriteLine("Creating Asset cache");
67 _assetServer = assetServer; 67 _assetServer = assetServer;
68 _assetServer.SetReceiver(this); 68 _assetServer.SetReceiver(this);
69 Assets = new Dictionary<LLUUID, AssetInfo>(); 69 Assets = new Dictionary<LLUUID, AssetInfo>();
70 Textures = new Dictionary<LLUUID, TextureImage>(); 70 Textures = new Dictionary<LLUUID, TextureImage>();
71 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); 71 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
72 this._assetCacheThread.IsBackground = true; 72 this._assetCacheThread.IsBackground = true;
73 this._assetCacheThread.Start(); 73 this._assetCacheThread.Start();
74 74
75 } 75 }
76 76
77 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) 77 public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey)
78 { 78 {
79 Console.WriteLine("Creating Asset cache"); 79 Console.WriteLine("Creating Asset cache");
80 _assetServer = this.LoadAssetDll(assetServerDLLName); 80 _assetServer = this.LoadAssetDll(assetServerDLLName);
81 _assetServer.SetServerInfo(assetServerURL, assetServerKey); 81 _assetServer.SetServerInfo(assetServerURL, assetServerKey);
82 _assetServer.SetReceiver(this); 82 _assetServer.SetReceiver(this);
83 Assets = new Dictionary<LLUUID, AssetInfo>(); 83 Assets = new Dictionary<LLUUID, AssetInfo>();
84 Textures = new Dictionary<LLUUID, TextureImage>(); 84 Textures = new Dictionary<LLUUID, TextureImage>();
85 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); 85 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
86 this._assetCacheThread.IsBackground = true; 86 this._assetCacheThread.IsBackground = true;
87 this._assetCacheThread.Start(); 87 this._assetCacheThread.Start();
88 88
89 } 89 }
90 90
91 /// <summary> 91 /// <summary>
92 /// 92 ///
93 /// </summary> 93 /// </summary>
94 public void RunAssetManager() 94 public void RunAssetManager()
95 { 95 {
96 while (true) 96 while (true)
97 { 97 {
98 try 98 try
99 { 99 {
100 //Console.WriteLine("Asset cache loop"); 100 //Console.WriteLine("Asset cache loop");
101 this.ProcessAssetQueue(); 101 this.ProcessAssetQueue();
102 this.ProcessTextureQueue(); 102 this.ProcessTextureQueue();
103 Thread.Sleep(500); 103 Thread.Sleep(500);
104 } 104 }
105 catch (Exception e) 105 catch (Exception e)
106 { 106 {
107 Console.WriteLine(e.Message); 107 Console.WriteLine(e.Message);
108 } 108 }
109 } 109 }
110 } 110 }
111 111
112 public void LoadDefaultTextureSet() 112 public void LoadDefaultTextureSet()
113 { 113 {
114 //hack: so we can give each user a set of textures 114 //hack: so we can give each user a set of textures
115 textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); 115 textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001");
116 textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); 116 textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002");
117 textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); 117 textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003");
118 textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); 118 textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004");
119 textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); 119 textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005");
120 120
121 for (int i = 0; i < textureList.Length; i++) 121 for (int i = 0; i < textureList.Length; i++)
122 { 122 {
123 this._assetServer.RequestAsset(textureList[i], true); 123 this._assetServer.RequestAsset(textureList[i], true);
124 } 124 }
125 125
126 } 126 }
127 127
128 public AssetBase[] CreateNewInventorySet(LLUUID agentID) 128 public AssetBase[] CreateNewInventorySet(LLUUID agentID)
129 { 129 {
130 AssetBase[] inventorySet = new AssetBase[this.textureList.Length]; 130 AssetBase[] inventorySet = new AssetBase[this.textureList.Length];
131 for (int i = 0; i < textureList.Length; i++) 131 for (int i = 0; i < textureList.Length; i++)
132 { 132 {
133 if (this.Textures.ContainsKey(textureList[i])) 133 if (this.Textures.ContainsKey(textureList[i]))
134 { 134 {
135 inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]); 135 inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]);
136 TextureImage image = new TextureImage(inventorySet[i]); 136 TextureImage image = new TextureImage(inventorySet[i]);
137 this.Textures.Add(image.FullID, image); 137 this.Textures.Add(image.FullID, image);
138 this._assetServer.UploadNewAsset(image); //save the asset to the asset server 138 this._assetServer.UploadNewAsset(image); //save the asset to the asset server
139 } 139 }
140 } 140 }
141 return inventorySet; 141 return inventorySet;
142 } 142 }
143 143
144 public AssetBase GetAsset(LLUUID assetID) 144 public AssetBase GetAsset(LLUUID assetID)
145 { 145 {
146 AssetBase asset = null; 146 AssetBase asset = null;
147 if (this.Textures.ContainsKey(assetID)) 147 if (this.Textures.ContainsKey(assetID))
148 { 148 {
149 asset = this.Textures[assetID]; 149 asset = this.Textures[assetID];
150 } 150 }
151 else if (this.Assets.ContainsKey(assetID)) 151 else if (this.Assets.ContainsKey(assetID))
152 { 152 {
153 asset = this.Assets[assetID]; 153 asset = this.Assets[assetID];
154 } 154 }
155 return asset; 155 return asset;
156 } 156 }
157 157
158 public void AddAsset(AssetBase asset) 158 public void AddAsset(AssetBase asset)
159 { 159 {
160 // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); 160 // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated());
161 if (asset.Type == 0) 161 if (asset.Type == 0)
162 { 162 {
163 //Console.WriteLine("which is a texture"); 163 //Console.WriteLine("which is a texture");
164 if (!this.Textures.ContainsKey(asset.FullID)) 164 if (!this.Textures.ContainsKey(asset.FullID))
165 { //texture 165 { //texture
166 TextureImage textur = new TextureImage(asset); 166 TextureImage textur = new TextureImage(asset);
167 this.Textures.Add(textur.FullID, textur); 167 this.Textures.Add(textur.FullID, textur);
168 this._assetServer.UploadNewAsset(asset); 168 this._assetServer.UploadNewAsset(asset);
169 } 169 }
170 } 170 }
171 else 171 else
172 { 172 {
173 if (!this.Assets.ContainsKey(asset.FullID)) 173 if (!this.Assets.ContainsKey(asset.FullID))
174 { 174 {
175 AssetInfo assetInf = new AssetInfo(asset); 175 AssetInfo assetInf = new AssetInfo(asset);
176 this.Assets.Add(assetInf.FullID, assetInf); 176 this.Assets.Add(assetInf.FullID, assetInf);
177 this._assetServer.UploadNewAsset(asset); 177 this._assetServer.UploadNewAsset(asset);
178 } 178 }
179 } 179 }
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// 183 ///
184 /// </summary> 184 /// </summary>
185 private void ProcessTextureQueue() 185 private void ProcessTextureQueue()
186 { 186 {
187 if (this.TextureRequests.Count == 0) 187 if (this.TextureRequests.Count == 0)
188 { 188 {
189 //no requests waiting 189 //no requests waiting
190 return; 190 return;
191 } 191 }
192 int num; 192 int num;
193 num = this.TextureRequests.Count; 193 num = this.TextureRequests.Count;
194 194
195 AssetRequest req; 195 AssetRequest req;
196 for (int i = 0; i < num; i++) 196 for (int i = 0; i < num; i++)
197 { 197 {
198 req = (AssetRequest)this.TextureRequests[i]; 198 req = (AssetRequest)this.TextureRequests[i];
199 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) 199 if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID))
200 { 200 {
201 TextureSender sender = new TextureSender(req); 201 TextureSender sender = new TextureSender(req);
202 sender.OnComplete += this.TextureSent; 202 sender.OnComplete += this.TextureSent;
203 lock (this.SendingTextures) 203 lock (this.SendingTextures)
204 { 204 {
205 this.SendingTextures.Add(req.ImageInfo.FullID, sender); 205 this.SendingTextures.Add(req.ImageInfo.FullID, sender);
206 } 206 }
207 } 207 }
208 208
209 } 209 }
210 210
211 this.TextureRequests.Clear(); 211 this.TextureRequests.Clear();
212 } 212 }
213 213
214 /// <summary> 214 /// <summary>
215 /// Event handler, called by a TextureSender object to say that texture has been sent 215 /// Event handler, called by a TextureSender object to say that texture has been sent
216 /// </summary> 216 /// </summary>
217 /// <param name="sender"></param> 217 /// <param name="sender"></param>
218 public void TextureSent(TextureSender sender) 218 public void TextureSent(TextureSender sender)
219 { 219 {
220 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) 220 if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
221 { 221 {
222 lock (this.SendingTextures) 222 lock (this.SendingTextures)
223 { 223 {
224 this.SendingTextures.Remove(sender.request.ImageInfo.FullID); 224 this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
225 } 225 }
226 } 226 }
227 } 227 }
228 228
229 public void AssetReceived(AssetBase asset, bool IsTexture) 229 public void AssetReceived(AssetBase asset, bool IsTexture)
230 { 230 {
231 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server 231 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
232 { 232 {
233 //check if it is a texture or not 233 //check if it is a texture or not
234 //then add to the correct cache list 234 //then add to the correct cache list
235 //then check for waiting requests for this asset/texture (in the Requested lists) 235 //then check for waiting requests for this asset/texture (in the Requested lists)
236 //and move those requests into the Requests list. 236 //and move those requests into the Requests list.
237 if (IsTexture) 237 if (IsTexture)
238 { 238 {
239 TextureImage image = new TextureImage(asset); 239 TextureImage image = new TextureImage(asset);
240 this.Textures.Add(image.FullID, image); 240 this.Textures.Add(image.FullID, image);
241 if (this.RequestedTextures.ContainsKey(image.FullID)) 241 if (this.RequestedTextures.ContainsKey(image.FullID))
242 { 242 {
243 AssetRequest req = this.RequestedTextures[image.FullID]; 243 AssetRequest req = this.RequestedTextures[image.FullID];
244 req.ImageInfo = image; 244 req.ImageInfo = image;
245 if (image.Data.LongLength > 600) 245 if (image.Data.LongLength > 600)
246 { 246 {
247 //over 600 bytes so split up file 247 //over 600 bytes so split up file
248 req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; 248 req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000;
249 } 249 }
250 else 250 else
251 { 251 {
252 req.NumPackets = 1; 252 req.NumPackets = 1;
253 } 253 }
254 this.RequestedTextures.Remove(image.FullID); 254 this.RequestedTextures.Remove(image.FullID);
255 this.TextureRequests.Add(req); 255 this.TextureRequests.Add(req);
256 } 256 }
257 } 257 }
258 else 258 else
259 { 259 {
260 AssetInfo assetInf = new AssetInfo(asset); 260 AssetInfo assetInf = new AssetInfo(asset);
261 this.Assets.Add(assetInf.FullID, assetInf); 261 this.Assets.Add(assetInf.FullID, assetInf);
262 if (this.RequestedAssets.ContainsKey(assetInf.FullID)) 262 if (this.RequestedAssets.ContainsKey(assetInf.FullID))
263 { 263 {
264 AssetRequest req = this.RequestedAssets[assetInf.FullID]; 264 AssetRequest req = this.RequestedAssets[assetInf.FullID];
265 req.AssetInf = assetInf; 265 req.AssetInf = assetInf;
266 if (assetInf.Data.LongLength > 600) 266 if (assetInf.Data.LongLength > 600)
267 { 267 {
268 //over 600 bytes so split up file 268 //over 600 bytes so split up file
269 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; 269 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
270 } 270 }
271 else 271 else
272 { 272 {
273 req.NumPackets = 1; 273 req.NumPackets = 1;
274 } 274 }
275 this.RequestedAssets.Remove(assetInf.FullID); 275 this.RequestedAssets.Remove(assetInf.FullID);
276 this.AssetRequests.Add(req); 276 this.AssetRequests.Add(req);
277 } 277 }
278 } 278 }
279 } 279 }
280 } 280 }
281 281
282 public void AssetNotFound(AssetBase asset) 282 public void AssetNotFound(AssetBase asset)
283 { 283 {
284 //the asset server had no knowledge of requested asset 284 //the asset server had no knowledge of requested asset
285 285
286 } 286 }
287 287
288 #region Assets 288 #region Assets
289 /// <summary> 289 /// <summary>
290 /// 290 ///
291 /// </summary> 291 /// </summary>
292 /// <param name="userInfo"></param> 292 /// <param name="userInfo"></param>
293 /// <param name="transferRequest"></param> 293 /// <param name="transferRequest"></param>
294 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) 294 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
295 { 295 {
296 LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); 296 LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
297 //check to see if asset is in local cache, if not we need to request it from asset server. 297 //check to see if asset is in local cache, if not we need to request it from asset server.
298 298
299 if (!this.Assets.ContainsKey(requestID)) 299 if (!this.Assets.ContainsKey(requestID))
300 { 300 {
301 //not found asset 301 //not found asset
302 // so request from asset server 302 // so request from asset server
303 if (!this.RequestedAssets.ContainsKey(requestID)) 303 if (!this.RequestedAssets.ContainsKey(requestID))
304 { 304 {
305 AssetRequest request = new AssetRequest(); 305 AssetRequest request = new AssetRequest();
306 request.RequestUser = userInfo; 306 request.RequestUser = userInfo;
307 request.RequestAssetID = requestID; 307 request.RequestAssetID = requestID;
308 request.TransferRequestID = transferRequest.TransferInfo.TransferID; 308 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
309 this.RequestedAssets.Add(requestID, request); 309 this.RequestedAssets.Add(requestID, request);
310 this._assetServer.RequestAsset(requestID, false); 310 this._assetServer.RequestAsset(requestID, false);
311 } 311 }
312 return; 312 return;
313 } 313 }
314 //it is in our cache 314 //it is in our cache
315 AssetInfo asset = this.Assets[requestID]; 315 AssetInfo asset = this.Assets[requestID];
316 316
317 //work out how many packets it should be sent in 317 //work out how many packets it should be sent in
318 // and add to the AssetRequests list 318 // and add to the AssetRequests list
319 AssetRequest req = new AssetRequest(); 319 AssetRequest req = new AssetRequest();
320 req.RequestUser = userInfo; 320 req.RequestUser = userInfo;
321 req.RequestAssetID = requestID; 321 req.RequestAssetID = requestID;
322 req.TransferRequestID = transferRequest.TransferInfo.TransferID; 322 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
323 req.AssetInf = asset; 323 req.AssetInf = asset;
324 324
325 if (asset.Data.LongLength > 600) 325 if (asset.Data.LongLength > 600)
326 { 326 {
327 //over 600 bytes so split up file 327 //over 600 bytes so split up file
328 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; 328 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
329 } 329 }
330 else 330 else
331 { 331 {
332 req.NumPackets = 1; 332 req.NumPackets = 1;
333 } 333 }
334 334
335 this.AssetRequests.Add(req); 335 this.AssetRequests.Add(req);
336 } 336 }
337 337
338 /// <summary> 338 /// <summary>
339 /// 339 ///
340 /// </summary> 340 /// </summary>
341 private void ProcessAssetQueue() 341 private void ProcessAssetQueue()
342 { 342 {
343 if (this.AssetRequests.Count == 0) 343 if (this.AssetRequests.Count == 0)
344 { 344 {
345 //no requests waiting 345 //no requests waiting
346 return; 346 return;
347 } 347 }
348 int num; 348 int num;
349 349
350 if (this.AssetRequests.Count < 5) 350 if (this.AssetRequests.Count < 5)
351 { 351 {
352 //lower than 5 so do all of them 352 //lower than 5 so do all of them
353 num = this.AssetRequests.Count; 353 num = this.AssetRequests.Count;
354 } 354 }
355 else 355 else
356 { 356 {
357 num = 5; 357 num = 5;
358 } 358 }
359 AssetRequest req; 359 AssetRequest req;
360 for (int i = 0; i < num; i++) 360 for (int i = 0; i < num; i++)
361 { 361 {
362 req = (AssetRequest)this.AssetRequests[i]; 362 req = (AssetRequest)this.AssetRequests[i];
363 363
364 TransferInfoPacket Transfer = new TransferInfoPacket(); 364 TransferInfoPacket Transfer = new TransferInfoPacket();
365 Transfer.TransferInfo.ChannelType = 2; 365 Transfer.TransferInfo.ChannelType = 2;
366 Transfer.TransferInfo.Status = 0; 366 Transfer.TransferInfo.Status = 0;
367 Transfer.TransferInfo.TargetType = 0; 367 Transfer.TransferInfo.TargetType = 0;
368 Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); 368 Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes();
369 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; 369 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
370 Transfer.TransferInfo.TransferID = req.TransferRequestID; 370 Transfer.TransferInfo.TransferID = req.TransferRequestID;
371 req.RequestUser.OutPacket(Transfer); 371 req.RequestUser.OutPacket(Transfer);
372 372
373 if (req.NumPackets == 1) 373 if (req.NumPackets == 1)
374 { 374 {
375 TransferPacketPacket TransferPacket = new TransferPacketPacket(); 375 TransferPacketPacket TransferPacket = new TransferPacketPacket();
376 TransferPacket.TransferData.Packet = 0; 376 TransferPacket.TransferData.Packet = 0;
377 TransferPacket.TransferData.ChannelType = 2; 377 TransferPacket.TransferData.ChannelType = 2;
378 TransferPacket.TransferData.TransferID = req.TransferRequestID; 378 TransferPacket.TransferData.TransferID = req.TransferRequestID;
379 TransferPacket.TransferData.Data = req.AssetInf.Data; 379 TransferPacket.TransferData.Data = req.AssetInf.Data;
380 TransferPacket.TransferData.Status = 1; 380 TransferPacket.TransferData.Status = 1;
381 req.RequestUser.OutPacket(TransferPacket); 381 req.RequestUser.OutPacket(TransferPacket);
382 } 382 }
383 else 383 else
384 { 384 {
385 //more than one packet so split file up , for now it can't be bigger than 2000 bytes 385 //more than one packet so split file up , for now it can't be bigger than 2000 bytes
386 TransferPacketPacket TransferPacket = new TransferPacketPacket(); 386 TransferPacketPacket TransferPacket = new TransferPacketPacket();
387 TransferPacket.TransferData.Packet = 0; 387 TransferPacket.TransferData.Packet = 0;
388 TransferPacket.TransferData.ChannelType = 2; 388 TransferPacket.TransferData.ChannelType = 2;
389 TransferPacket.TransferData.TransferID = req.TransferRequestID; 389 TransferPacket.TransferData.TransferID = req.TransferRequestID;
390 byte[] chunk = new byte[1000]; 390 byte[] chunk = new byte[1000];
391 Array.Copy(req.AssetInf.Data, chunk, 1000); 391 Array.Copy(req.AssetInf.Data, chunk, 1000);
392 TransferPacket.TransferData.Data = chunk; 392 TransferPacket.TransferData.Data = chunk;
393 TransferPacket.TransferData.Status = 0; 393 TransferPacket.TransferData.Status = 0;
394 req.RequestUser.OutPacket(TransferPacket); 394 req.RequestUser.OutPacket(TransferPacket);
395 395
396 TransferPacket = new TransferPacketPacket(); 396 TransferPacket = new TransferPacketPacket();
397 TransferPacket.TransferData.Packet = 1; 397 TransferPacket.TransferData.Packet = 1;
398 TransferPacket.TransferData.ChannelType = 2; 398 TransferPacket.TransferData.ChannelType = 2;
399 TransferPacket.TransferData.TransferID = req.TransferRequestID; 399 TransferPacket.TransferData.TransferID = req.TransferRequestID;
400 byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; 400 byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
401 Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); 401 Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
402 TransferPacket.TransferData.Data = chunk1; 402 TransferPacket.TransferData.Data = chunk1;
403 TransferPacket.TransferData.Status = 1; 403 TransferPacket.TransferData.Status = 1;
404 req.RequestUser.OutPacket(TransferPacket); 404 req.RequestUser.OutPacket(TransferPacket);
405 } 405 }
406 406
407 } 407 }
408 408
409 //remove requests that have been completed 409 //remove requests that have been completed
410 for (int i = 0; i < num; i++) 410 for (int i = 0; i < num; i++)
411 { 411 {
412 this.AssetRequests.RemoveAt(0); 412 this.AssetRequests.RemoveAt(0);
413 } 413 }
414 414
415 } 415 }
416 416
417 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) 417 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
418 { 418 {
419 AssetInfo newAsset = new AssetInfo(); 419 AssetInfo newAsset = new AssetInfo();
420 newAsset.Data = new byte[sourceAsset.Data.Length]; 420 newAsset.Data = new byte[sourceAsset.Data.Length];
421 Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); 421 Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length);
422 newAsset.FullID = LLUUID.Random(); 422 newAsset.FullID = LLUUID.Random();
423 newAsset.Type = sourceAsset.Type; 423 newAsset.Type = sourceAsset.Type;
424 newAsset.InvType = sourceAsset.InvType; 424 newAsset.InvType = sourceAsset.InvType;
425 return (newAsset); 425 return (newAsset);
426 } 426 }
427 #endregion 427 #endregion
428 428
429 #region Textures 429 #region Textures
430 /// <summary> 430 /// <summary>
431 /// 431 ///
432 /// </summary> 432 /// </summary>
433 /// <param name="userInfo"></param> 433 /// <param name="userInfo"></param>
434 /// <param name="imageID"></param> 434 /// <param name="imageID"></param>
435 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) 435 public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID)
436 { 436 {
437 //Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); 437 //Console.WriteLine("texture request for " + imageID.ToStringHyphenated());
438 //check to see if texture is in local cache, if not request from asset server 438 //check to see if texture is in local cache, if not request from asset server
439 if (!this.Textures.ContainsKey(imageID)) 439 if (!this.Textures.ContainsKey(imageID))
440 { 440 {
441 if (!this.RequestedTextures.ContainsKey(imageID)) 441 if (!this.RequestedTextures.ContainsKey(imageID))
442 { 442 {
443 //not is cache so request from asset server 443 //not is cache so request from asset server
444 AssetRequest request = new AssetRequest(); 444 AssetRequest request = new AssetRequest();
445 request.RequestUser = userInfo; 445 request.RequestUser = userInfo;
446 request.RequestAssetID = imageID; 446 request.RequestAssetID = imageID;
447 request.IsTextureRequest = true; 447 request.IsTextureRequest = true;
448 this.RequestedTextures.Add(imageID, request); 448 this.RequestedTextures.Add(imageID, request);
449 this._assetServer.RequestAsset(imageID, true); 449 this._assetServer.RequestAsset(imageID, true);
450 } 450 }
451 return; 451 return;
452 } 452 }
453 453
454 //Console.WriteLine("texture already in cache"); 454 //Console.WriteLine("texture already in cache");
455 TextureImage imag = this.Textures[imageID]; 455 TextureImage imag = this.Textures[imageID];
456 AssetRequest req = new AssetRequest(); 456 AssetRequest req = new AssetRequest();
457 req.RequestUser = userInfo; 457 req.RequestUser = userInfo;
458 req.RequestAssetID = imageID; 458 req.RequestAssetID = imageID;
459 req.IsTextureRequest = true; 459 req.IsTextureRequest = true;
460 req.ImageInfo = imag; 460 req.ImageInfo = imag;
461 461
462 if (imag.Data.LongLength > 600) 462 if (imag.Data.LongLength > 600)
463 { 463 {
464 //over 600 bytes so split up file 464 //over 600 bytes so split up file
465 req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; 465 req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000;
466 } 466 }
467 else 467 else
468 { 468 {
469 req.NumPackets = 1; 469 req.NumPackets = 1;
470 } 470 }
471 this.TextureRequests.Add(req); 471 this.TextureRequests.Add(req);
472 } 472 }
473 473
474 public TextureImage CloneImage(LLUUID newOwner, TextureImage source) 474 public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
475 { 475 {
476 TextureImage newImage = new TextureImage(); 476 TextureImage newImage = new TextureImage();
477 newImage.Data = new byte[source.Data.Length]; 477 newImage.Data = new byte[source.Data.Length];
478 Array.Copy(source.Data, newImage.Data, source.Data.Length); 478 Array.Copy(source.Data, newImage.Data, source.Data.Length);
479 //newImage.filename = source.filename; 479 //newImage.filename = source.filename;
480 newImage.FullID = LLUUID.Random(); 480 newImage.FullID = LLUUID.Random();
481 newImage.Name = source.Name; 481 newImage.Name = source.Name;
482 return (newImage); 482 return (newImage);
483 } 483 }
484 #endregion 484 #endregion
485 485
486 private IAssetServer LoadAssetDll(string dllName) 486 private IAssetServer LoadAssetDll(string dllName)
487 { 487 {
488 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 488 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
489 IAssetServer server = null; 489 IAssetServer server = null;
490 490
491 foreach (Type pluginType in pluginAssembly.GetTypes()) 491 foreach (Type pluginType in pluginAssembly.GetTypes())
492 { 492 {
493 if (pluginType.IsPublic) 493 if (pluginType.IsPublic)
494 { 494 {
495 if (!pluginType.IsAbstract) 495 if (!pluginType.IsAbstract)
496 { 496 {
497 Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); 497 Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
498 498
499 if (typeInterface != null) 499 if (typeInterface != null)
500 { 500 {
501 IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 501 IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
502 server = plug.GetAssetServer(); 502 server = plug.GetAssetServer();
503 break; 503 break;
504 } 504 }
505 505
506 typeInterface = null; 506 typeInterface = null;
507 } 507 }
508 } 508 }
509 } 509 }
510 pluginAssembly = null; 510 pluginAssembly = null;
511 return server; 511 return server;
512 } 512 }
513 513
514 public class AssetRequest 514 public class AssetRequest
515 { 515 {
516 public IClientAPI RequestUser; 516 public IClientAPI RequestUser;
517 public LLUUID RequestAssetID; 517 public LLUUID RequestAssetID;
518 public AssetInfo AssetInf; 518 public AssetInfo AssetInf;
519 public TextureImage ImageInfo; 519 public TextureImage ImageInfo;
520 public LLUUID TransferRequestID; 520 public LLUUID TransferRequestID;
521 public long DataPointer = 0; 521 public long DataPointer = 0;
522 public int NumPackets = 0; 522 public int NumPackets = 0;
523 public int PacketCounter = 0; 523 public int PacketCounter = 0;
524 public bool IsTextureRequest; 524 public bool IsTextureRequest;
525 //public bool AssetInCache; 525 //public bool AssetInCache;
526 //public int TimeRequested; 526 //public int TimeRequested;
527 527
528 public AssetRequest() 528 public AssetRequest()
529 { 529 {
530 530
531 } 531 }
532 } 532 }
533 533
534 public class AssetInfo : AssetBase 534 public class AssetInfo : AssetBase
535 { 535 {
536 public AssetInfo() 536 public AssetInfo()
537 { 537 {
538 538
539 } 539 }
540 540
541 public AssetInfo(AssetBase aBase) 541 public AssetInfo(AssetBase aBase)
542 { 542 {
543 Data = aBase.Data; 543 Data = aBase.Data;
544 FullID = aBase.FullID; 544 FullID = aBase.FullID;
545 Type = aBase.Type; 545 Type = aBase.Type;
546 InvType = aBase.InvType; 546 InvType = aBase.InvType;
547 Name = aBase.Name; 547 Name = aBase.Name;
548 Description = aBase.Description; 548 Description = aBase.Description;
549 } 549 }
550 } 550 }
551 551
552 public class TextureImage : AssetBase 552 public class TextureImage : AssetBase
553 { 553 {
554 public TextureImage() 554 public TextureImage()
555 { 555 {
556 556
557 } 557 }
558 558
559 public TextureImage(AssetBase aBase) 559 public TextureImage(AssetBase aBase)
560 { 560 {
561 Data = aBase.Data; 561 Data = aBase.Data;
562 FullID = aBase.FullID; 562 FullID = aBase.FullID;
563 Type = aBase.Type; 563 Type = aBase.Type;
564 InvType = aBase.InvType; 564 InvType = aBase.InvType;
565 Name = aBase.Name; 565 Name = aBase.Name;
566 Description = aBase.Description; 566 Description = aBase.Description;
567 } 567 }
568 } 568 }
569 569
570 public class TextureSender 570 public class TextureSender
571 { 571 {
572 public AssetRequest request; 572 public AssetRequest request;
573 public event DownloadComplete OnComplete; 573 public event DownloadComplete OnComplete;
574 Thread m_thread; 574 Thread m_thread;
575 public TextureSender(AssetRequest req) 575 public TextureSender(AssetRequest req)
576 { 576 {
577 request = req; 577 request = req;
578 //Console.WriteLine("creating worker thread for texture " + req.ImageInfo.FullID.ToStringHyphenated()); 578 //Console.WriteLine("creating worker thread for texture " + req.ImageInfo.FullID.ToStringHyphenated());
579 //Console.WriteLine("texture data length is " + req.ImageInfo.Data.Length); 579 //Console.WriteLine("texture data length is " + req.ImageInfo.Data.Length);
580 // Console.WriteLine("in " + req.NumPackets + " packets"); 580 // Console.WriteLine("in " + req.NumPackets + " packets");
581 //ThreadPool.QueueUserWorkItem(new WaitCallback(SendTexture), new object()); 581 //ThreadPool.QueueUserWorkItem(new WaitCallback(SendTexture), new object());
582 582
583 //need some sort of custom threadpool here, as using the .net one, overloads it and stops the handling of incoming packets etc 583 //need some sort of custom threadpool here, as using the .net one, overloads it and stops the handling of incoming packets etc
584 //but don't really want to create a thread for every texture download 584 //but don't really want to create a thread for every texture download
585 m_thread = new Thread(new ThreadStart(SendTexture)); 585 m_thread = new Thread(new ThreadStart(SendTexture));
586 m_thread.IsBackground = true; 586 m_thread.IsBackground = true;
587 m_thread.Start(); 587 m_thread.Start();
588 } 588 }
589 589
590 public void SendTexture() 590 public void SendTexture()
591 { 591 {
592 //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); 592 //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
593 while (request.PacketCounter != request.NumPackets) 593 while (request.PacketCounter != request.NumPackets)
594 { 594 {
595 SendPacket(); 595 SendPacket();
596 Thread.Sleep(500); 596 Thread.Sleep(500);
597 } 597 }
598 598
599 //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); 599 //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated());
600 if (OnComplete != null) 600 if (OnComplete != null)
601 { 601 {
602 OnComplete(this); 602 OnComplete(this);
603 } 603 }
604 } 604 }
605 605
606 public void SendPacket() 606 public void SendPacket()
607 { 607 {
608 AssetRequest req = request; 608 AssetRequest req = request;
609 // Console.WriteLine("sending " + req.ImageInfo.FullID); 609 // Console.WriteLine("sending " + req.ImageInfo.FullID);
610 610
611 // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) 611 // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005"))
612 if (req.PacketCounter == 0) 612 if (req.PacketCounter == 0)
613 { 613 {
614 //first time for this request so send imagedata packet 614 //first time for this request so send imagedata packet
615 if (req.NumPackets == 1) 615 if (req.NumPackets == 1)
616 { 616 {
617 //only one packet so send whole file 617 //only one packet so send whole file
618 ImageDataPacket im = new ImageDataPacket(); 618 ImageDataPacket im = new ImageDataPacket();
619 im.ImageID.Packets = 1; 619 im.ImageID.Packets = 1;
620 im.ImageID.ID = req.ImageInfo.FullID; 620 im.ImageID.ID = req.ImageInfo.FullID;
621 im.ImageID.Size = (uint)req.ImageInfo.Data.Length; 621 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
622 im.ImageData.Data = req.ImageInfo.Data; 622 im.ImageData.Data = req.ImageInfo.Data;
623 im.ImageID.Codec = 2; 623 im.ImageID.Codec = 2;
624 req.RequestUser.OutPacket(im); 624 req.RequestUser.OutPacket(im);
625 req.PacketCounter++; 625 req.PacketCounter++;
626 //req.ImageInfo.l= time; 626 //req.ImageInfo.l= time;
627 //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); 627 //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
628 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); 628 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
629 } 629 }
630 else 630 else
631 { 631 {
632 //more than one packet so split file up 632 //more than one packet so split file up
633 ImageDataPacket im = new ImageDataPacket(); 633 ImageDataPacket im = new ImageDataPacket();
634 im.ImageID.Packets = (ushort)req.NumPackets; 634 im.ImageID.Packets = (ushort)req.NumPackets;
635 im.ImageID.ID = req.ImageInfo.FullID; 635 im.ImageID.ID = req.ImageInfo.FullID;
636 im.ImageID.Size = (uint)req.ImageInfo.Data.Length; 636 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
637 im.ImageData.Data = new byte[600]; 637 im.ImageData.Data = new byte[600];
638 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); 638 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
639 im.ImageID.Codec = 2; 639 im.ImageID.Codec = 2;
640 req.RequestUser.OutPacket(im); 640 req.RequestUser.OutPacket(im);
641 req.PacketCounter++; 641 req.PacketCounter++;
642 //req.ImageInfo.last_used = time; 642 //req.ImageInfo.last_used = time;
643 //System.Console.WriteLine("sent first packet of texture: 643 //System.Console.WriteLine("sent first packet of texture:
644 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); 644 // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
645 } 645 }
646 } 646 }
647 else 647 else
648 { 648 {
649 //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); 649 //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated());
650 //send imagepacket 650 //send imagepacket
651 //more than one packet so split file up 651 //more than one packet so split file up
652 ImagePacketPacket im = new ImagePacketPacket(); 652 ImagePacketPacket im = new ImagePacketPacket();
653 im.ImageID.Packet = (ushort)req.PacketCounter; 653 im.ImageID.Packet = (ushort)req.PacketCounter;
654 im.ImageID.ID = req.ImageInfo.FullID; 654 im.ImageID.ID = req.ImageInfo.FullID;
655 int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); 655 int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1);
656 if (size > 1000) size = 1000; 656 if (size > 1000) size = 1000;
657 im.ImageData.Data = new byte[size]; 657 im.ImageData.Data = new byte[size];
658 Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size); 658 Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size);
659 req.RequestUser.OutPacket(im); 659 req.RequestUser.OutPacket(im);
660 req.PacketCounter++; 660 req.PacketCounter++;
661 //req.ImageInfo.last_used = time; 661 //req.ImageInfo.last_used = time;
662 //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); 662 //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
663 } 663 }
664 664
665 } 665 }
666 } 666 }
667 } 667 }
668} 668}
669 669
diff --git a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
index 8389415..4ba42b9 100644
--- a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs
@@ -1,33 +1,33 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following 3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Region.Caches")] 6[assembly: AssemblyTitle("OpenSim.Region.Caches")]
7[assembly: AssemblyDescription("")] 7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")] 8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")] 9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Region.Caches")] 10[assembly: AssemblyProduct("OpenSim.Region.Caches")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")] 12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")] 13[assembly: AssemblyCulture("")]
14 14
15// Setting ComVisible to false makes the types in this assembly not visible 15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 18[assembly: ComVisible(false)]
19 19
20// The following GUID is for the ID of the typelib if this project is exposed to COM 20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")] 21[assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")]
22 22
23// Version information for an assembly consists of the following four values: 23// Version information for an assembly consists of the following four values:
24// 24//
25// Major Version 25// Major Version
26// Minor Version 26// Minor Version
27// Build Number 27// Build Number
28// Revision 28// Revision
29// 29//
30// You can specify all the values or you can default the Revision and Build Numbers 30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")] 33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
index 7acbf8e..d2ef526 100644
--- a/OpenSim/Region/Capabilities/Caps.cs
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -1,313 +1,313 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.IO; 32using System.IO;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Servers; 34using OpenSim.Framework.Servers;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Region.Caches; 37using OpenSim.Region.Caches;
38 38
39namespace OpenSim.Region.Capabilities 39namespace OpenSim.Region.Capabilities
40{ 40{
41 public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data); 41 public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data);
42 42
43 public class Caps 43 public class Caps
44 { 44 {
45 private string m_httpListenerHostName; 45 private string m_httpListenerHostName;
46 private int m_httpListenPort; 46 private int m_httpListenPort;
47 private string m_capsObjectPath = "00001-"; 47 private string m_capsObjectPath = "00001-";
48 private string m_requestPath = "0000/"; 48 private string m_requestPath = "0000/";
49 private string m_mapLayerPath = "0001/"; 49 private string m_mapLayerPath = "0001/";
50 private string m_newInventory = "0002/"; 50 private string m_newInventory = "0002/";
51 // private string m_requestTexture = "0003/"; 51 // private string m_requestTexture = "0003/";
52 //private string eventQueue = "0100/"; 52 //private string eventQueue = "0100/";
53 private BaseHttpServer httpListener; 53 private BaseHttpServer httpListener;
54 private LLUUID agentID; 54 private LLUUID agentID;
55 private AssetCache assetCache; 55 private AssetCache assetCache;
56 private int eventQueueCount = 1; 56 private int eventQueueCount = 1;
57 private Queue<string> CapsEventQueue = new Queue<string>(); 57 private Queue<string> CapsEventQueue = new Queue<string>();
58 58
59 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) 59 public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent)
60 { 60 {
61 assetCache = assetCach; 61 assetCache = assetCach;
62 m_capsObjectPath = capsPath; 62 m_capsObjectPath = capsPath;
63 httpListener = httpServer; 63 httpListener = httpServer;
64 m_httpListenerHostName = httpListen; 64 m_httpListenerHostName = httpListen;
65 m_httpListenPort = httpPort; 65 m_httpListenPort = httpPort;
66 agentID = agent; 66 agentID = agent;
67 } 67 }
68 68
69 /// <summary> 69 /// <summary>
70 /// 70 ///
71 /// </summary> 71 /// </summary>
72 public void RegisterHandlers() 72 public void RegisterHandlers()
73 { 73 {
74 Console.WriteLine("registering CAPS handlers"); 74 Console.WriteLine("registering CAPS handlers");
75 string capsBase = "/CAPS/" + m_capsObjectPath; 75 string capsBase = "/CAPS/" + m_capsObjectPath;
76 76
77 httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); 77 httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
78 httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); 78 httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest));
79 79
80 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); 80 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
81 // AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue); 81 // AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue);
82 // AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture); 82 // AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture);
83 } 83 }
84 84
85 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] 85 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
86 private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) 86 private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
87 { 87 {
88 string capsBase = "/CAPS/" + m_capsObjectPath; 88 string capsBase = "/CAPS/" + m_capsObjectPath;
89 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); 89 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
90 } 90 }
91 91
92 /// <summary> 92 /// <summary>
93 /// 93 ///
94 /// </summary> 94 /// </summary>
95 /// <param name="request"></param> 95 /// <param name="request"></param>
96 /// <param name="path"></param> 96 /// <param name="path"></param>
97 /// <param name="param"></param> 97 /// <param name="param"></param>
98 /// <returns></returns> 98 /// <returns></returns>
99 public string CapsRequest(string request, string path, string param) 99 public string CapsRequest(string request, string path, string param)
100 { 100 {
101 // Console.WriteLine("caps request " + request); 101 // Console.WriteLine("caps request " + request);
102 string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); 102 string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
103 return result; 103 return result;
104 } 104 }
105 105
106 /// <summary> 106 /// <summary>
107 /// 107 ///
108 /// </summary> 108 /// </summary>
109 /// <returns></returns> 109 /// <returns></returns>
110 protected LLSDCapsDetails GetCapabilities() 110 protected LLSDCapsDetails GetCapabilities()
111 { 111 {
112 LLSDCapsDetails caps = new LLSDCapsDetails(); 112 LLSDCapsDetails caps = new LLSDCapsDetails();
113 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; 113 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
114 caps.MapLayer = capsBaseUrl + m_mapLayerPath; 114 caps.MapLayer = capsBaseUrl + m_mapLayerPath;
115 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; 115 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
116 //caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; 116 //caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
117 // caps.ChatSessionRequest = capsBaseUrl + m_requestTexture; 117 // caps.ChatSessionRequest = capsBaseUrl + m_requestTexture;
118 return caps; 118 return caps;
119 } 119 }
120 120
121 /// <summary> 121 /// <summary>
122 /// 122 ///
123 /// </summary> 123 /// </summary>
124 /// <param name="mapReq"></param> 124 /// <param name="mapReq"></param>
125 /// <returns></returns> 125 /// <returns></returns>
126 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) 126 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
127 { 127 {
128 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); 128 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
129 mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); 129 mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse());
130 return mapResponse; 130 return mapResponse;
131 } 131 }
132 132
133 /// <summary> 133 /// <summary>
134 /// 134 ///
135 /// </summary> 135 /// </summary>
136 /// <returns></returns> 136 /// <returns></returns>
137 protected LLSDMapLayer GetLLSDMapLayerResponse() 137 protected LLSDMapLayer GetLLSDMapLayerResponse()
138 { 138 {
139 LLSDMapLayer mapLayer = new LLSDMapLayer(); 139 LLSDMapLayer mapLayer = new LLSDMapLayer();
140 mapLayer.Right = 5000; 140 mapLayer.Right = 5000;
141 mapLayer.Top = 5000; 141 mapLayer.Top = 5000;
142 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); 142 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
143 return mapLayer; 143 return mapLayer;
144 } 144 }
145 145
146 /// <summary> 146 /// <summary>
147 /// 147 ///
148 /// </summary> 148 /// </summary>
149 /// <param name="request"></param> 149 /// <param name="request"></param>
150 /// <param name="path"></param> 150 /// <param name="path"></param>
151 /// <param name="param"></param> 151 /// <param name="param"></param>
152 /// <returns></returns> 152 /// <returns></returns>
153 public string RequestTexture(string request, string path, string param) 153 public string RequestTexture(string request, string path, string param)
154 { 154 {
155 Console.WriteLine("texture request " + request); 155 Console.WriteLine("texture request " + request);
156 // Needs implementing (added to remove compiler warning) 156 // Needs implementing (added to remove compiler warning)
157 return ""; 157 return "";
158 } 158 }
159 159
160 #region EventQueue (Currently not enabled) 160 #region EventQueue (Currently not enabled)
161 /// <summary> 161 /// <summary>
162 /// 162 ///
163 /// </summary> 163 /// </summary>
164 /// <param name="request"></param> 164 /// <param name="request"></param>
165 /// <param name="path"></param> 165 /// <param name="path"></param>
166 /// <param name="param"></param> 166 /// <param name="param"></param>
167 /// <returns></returns> 167 /// <returns></returns>
168 public string ProcessEventQueue(string request, string path, string param) 168 public string ProcessEventQueue(string request, string path, string param)
169 { 169 {
170 string res = ""; 170 string res = "";
171 171
172 if (this.CapsEventQueue.Count > 0) 172 if (this.CapsEventQueue.Count > 0)
173 { 173 {
174 lock (this.CapsEventQueue) 174 lock (this.CapsEventQueue)
175 { 175 {
176 string item = CapsEventQueue.Dequeue(); 176 string item = CapsEventQueue.Dequeue();
177 res = item; 177 res = item;
178 } 178 }
179 } 179 }
180 else 180 else
181 { 181 {
182 res = this.CreateEmptyEventResponse(); 182 res = this.CreateEmptyEventResponse();
183 } 183 }
184 return res; 184 return res;
185 } 185 }
186 186
187 /// <summary> 187 /// <summary>
188 /// 188 ///
189 /// </summary> 189 /// </summary>
190 /// <param name="caps"></param> 190 /// <param name="caps"></param>
191 /// <param name="ipAddressPort"></param> 191 /// <param name="ipAddressPort"></param>
192 /// <returns></returns> 192 /// <returns></returns>
193 public string CreateEstablishAgentComms(string caps, string ipAddressPort) 193 public string CreateEstablishAgentComms(string caps, string ipAddressPort)
194 { 194 {
195 LLSDCapEvent eventItem = new LLSDCapEvent(); 195 LLSDCapEvent eventItem = new LLSDCapEvent();
196 eventItem.id = eventQueueCount; 196 eventItem.id = eventQueueCount;
197 //should be creating a EstablishAgentComms item, but there isn't a class for it yet 197 //should be creating a EstablishAgentComms item, but there isn't a class for it yet
198 eventItem.events.Array.Add(new LLSDEmpty()); 198 eventItem.events.Array.Add(new LLSDEmpty());
199 string res = LLSDHelpers.SerialiseLLSDReply(eventItem); 199 string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
200 eventQueueCount++; 200 eventQueueCount++;
201 201
202 this.CapsEventQueue.Enqueue(res); 202 this.CapsEventQueue.Enqueue(res);
203 return res; 203 return res;
204 } 204 }
205 205
206 /// <summary> 206 /// <summary>
207 /// 207 ///
208 /// </summary> 208 /// </summary>
209 /// <returns></returns> 209 /// <returns></returns>
210 public string CreateEmptyEventResponse() 210 public string CreateEmptyEventResponse()
211 { 211 {
212 LLSDCapEvent eventItem = new LLSDCapEvent(); 212 LLSDCapEvent eventItem = new LLSDCapEvent();
213 eventItem.id = eventQueueCount; 213 eventItem.id = eventQueueCount;
214 eventItem.events.Array.Add(new LLSDEmpty()); 214 eventItem.events.Array.Add(new LLSDEmpty());
215 string res = LLSDHelpers.SerialiseLLSDReply(eventItem); 215 string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
216 eventQueueCount++; 216 eventQueueCount++;
217 return res; 217 return res;
218 } 218 }
219 #endregion 219 #endregion
220 220
221 /// <summary> 221 /// <summary>
222 /// 222 ///
223 /// </summary> 223 /// </summary>
224 /// <param name="llsdRequest"></param> 224 /// <param name="llsdRequest"></param>
225 /// <returns></returns> 225 /// <returns></returns>
226 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) 226 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
227 { 227 {
228 string capsBase = "/CAPS/" + m_capsObjectPath; 228 string capsBase = "/CAPS/" + m_capsObjectPath;
229 LLUUID newAsset = LLUUID.Random(); 229 LLUUID newAsset = LLUUID.Random();
230 LLUUID newInvItem = LLUUID.Random(); 230 LLUUID newInvItem = LLUUID.Random();
231 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 231 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
232 232
233 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); 233 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, capsBase + uploaderPath, this.httpListener);
234 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); 234 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
235 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; 235 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
236 236
237 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); 237 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
238 uploadResponse.uploader = uploaderURL; 238 uploadResponse.uploader = uploaderURL;
239 uploadResponse.state = "upload"; 239 uploadResponse.state = "upload";
240 uploader.OnUpLoad += this.UploadCompleteHandler; 240 uploader.OnUpLoad += this.UploadCompleteHandler;
241 return uploadResponse; 241 return uploadResponse;
242 } 242 }
243 243
244 /// <summary> 244 /// <summary>
245 /// 245 ///
246 /// </summary> 246 /// </summary>
247 /// <param name="assetID"></param> 247 /// <param name="assetID"></param>
248 /// <param name="inventoryItem"></param> 248 /// <param name="inventoryItem"></param>
249 /// <param name="data"></param> 249 /// <param name="data"></param>
250 public void UploadCompleteHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) 250 public void UploadCompleteHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data)
251 { 251 {
252 AssetBase asset; 252 AssetBase asset;
253 asset = new AssetBase(); 253 asset = new AssetBase();
254 asset.FullID = assetID; 254 asset.FullID = assetID;
255 asset.Type = 0; 255 asset.Type = 0;
256 asset.InvType = 0; 256 asset.InvType = 0;
257 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); 257 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
258 asset.Data = data; 258 asset.Data = data;
259 this.assetCache.AddAsset(asset); 259 this.assetCache.AddAsset(asset);
260 } 260 }
261 261
262 public class AssetUploader 262 public class AssetUploader
263 { 263 {
264 public event UpLoadedTexture OnUpLoad; 264 public event UpLoadedTexture OnUpLoad;
265 265
266 private string uploaderPath = ""; 266 private string uploaderPath = "";
267 private LLUUID newAssetID; 267 private LLUUID newAssetID;
268 private LLUUID inventoryItemID; 268 private LLUUID inventoryItemID;
269 private BaseHttpServer httpListener; 269 private BaseHttpServer httpListener;
270 270
271 /// <summary> 271 /// <summary>
272 /// 272 ///
273 /// </summary> 273 /// </summary>
274 /// <param name="assetID"></param> 274 /// <param name="assetID"></param>
275 /// <param name="inventoryItem"></param> 275 /// <param name="inventoryItem"></param>
276 /// <param name="path"></param> 276 /// <param name="path"></param>
277 /// <param name="httpServer"></param> 277 /// <param name="httpServer"></param>
278 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) 278 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer)
279 { 279 {
280 newAssetID = assetID; 280 newAssetID = assetID;
281 inventoryItemID = inventoryItem; 281 inventoryItemID = inventoryItem;
282 uploaderPath = path; 282 uploaderPath = path;
283 httpListener = httpServer; 283 httpListener = httpServer;
284 } 284 }
285 285
286 /// <summary> 286 /// <summary>
287 /// 287 ///
288 /// </summary> 288 /// </summary>
289 /// <param name="data"></param> 289 /// <param name="data"></param>
290 /// <param name="path"></param> 290 /// <param name="path"></param>
291 /// <param name="param"></param> 291 /// <param name="param"></param>
292 /// <returns></returns> 292 /// <returns></returns>
293 public string uploaderCaps(byte[] data, string path, string param) 293 public string uploaderCaps(byte[] data, string path, string param)
294 { 294 {
295 LLUUID inv = this.inventoryItemID; 295 LLUUID inv = this.inventoryItemID;
296 string res = ""; 296 string res = "";
297 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); 297 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
298 uploadComplete.new_asset = newAssetID.ToStringHyphenated(); 298 uploadComplete.new_asset = newAssetID.ToStringHyphenated();
299 uploadComplete.new_inventory_item = inv; 299 uploadComplete.new_inventory_item = inv;
300 uploadComplete.state = "complete"; 300 uploadComplete.state = "complete";
301 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); 301 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
302 302
303 httpListener.RemoveStreamHandler("POST", uploaderPath); 303 httpListener.RemoveStreamHandler("POST", uploaderPath);
304 304
305 if (OnUpLoad != null) 305 if (OnUpLoad != null)
306 { 306 {
307 OnUpLoad(newAssetID, inv, data); 307 OnUpLoad(newAssetID, inv, data);
308 } 308 }
309 return res; 309 return res;
310 } 310 }
311 } 311 }
312 } 312 }
313} 313}
diff --git a/OpenSim/Region/Capabilities/LLSDArray.cs b/OpenSim/Region/Capabilities/LLSDArray.cs
index e04849f..d3e1979 100644
--- a/OpenSim/Region/Capabilities/LLSDArray.cs
+++ b/OpenSim/Region/Capabilities/LLSDArray.cs
@@ -1,42 +1,42 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections; 28using System.Collections;
29 29
30namespace OpenSim.Region.Capabilities 30namespace OpenSim.Region.Capabilities
31{ 31{
32 [LLSDType("ARRAY")] 32 [LLSDType("ARRAY")]
33 public class LLSDArray 33 public class LLSDArray
34 { 34 {
35 public ArrayList Array = new ArrayList(); 35 public ArrayList Array = new ArrayList();
36 36
37 public LLSDArray() 37 public LLSDArray()
38 { 38 {
39 39
40 } 40 }
41 } 41 }
42} 42}
diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs
index 1b78353..5718b8f 100644
--- a/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs
@@ -1,44 +1,44 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using libsecondlife; 28using libsecondlife;
29 29
30namespace OpenSim.Region.Capabilities 30namespace OpenSim.Region.Capabilities
31{ 31{
32 [LLSDType("MAP")] 32 [LLSDType("MAP")]
33 public class LLSDAssetUploadComplete 33 public class LLSDAssetUploadComplete
34 { 34 {
35 public string new_asset = ""; 35 public string new_asset = "";
36 public LLUUID new_inventory_item = LLUUID.Zero; 36 public LLUUID new_inventory_item = LLUUID.Zero;
37 public string state = ""; 37 public string state = "";
38 38
39 public LLSDAssetUploadComplete() 39 public LLSDAssetUploadComplete()
40 { 40 {
41 41
42 } 42 }
43 } 43 }
44} 44}
diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs
index 7ef77cb..0096fb1 100644
--- a/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs
@@ -1,21 +1,21 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5 5
6namespace OpenSim.Region.Capabilities 6namespace OpenSim.Region.Capabilities
7{ 7{
8 [LLSDMap] 8 [LLSDMap]
9 public class LLSDAssetUploadRequest 9 public class LLSDAssetUploadRequest
10 { 10 {
11 public string asset_type = ""; 11 public string asset_type = "";
12 public string description = ""; 12 public string description = "";
13 public LLUUID folder_id = LLUUID.Zero; 13 public LLUUID folder_id = LLUUID.Zero;
14 public string inventory_type = ""; 14 public string inventory_type = "";
15 public string name = ""; 15 public string name = "";
16 16
17 public LLSDAssetUploadRequest() 17 public LLSDAssetUploadRequest()
18 { 18 {
19 } 19 }
20 } 20 }
21} 21}
diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs
index 1a620ae..2a2a5d1 100644
--- a/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs
@@ -1,18 +1,18 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Capabilities 5namespace OpenSim.Region.Capabilities
6{ 6{
7 [LLSDMap] 7 [LLSDMap]
8 public class LLSDAssetUploadResponse 8 public class LLSDAssetUploadResponse
9 { 9 {
10 public string uploader = ""; 10 public string uploader = "";
11 public string state = ""; 11 public string state = "";
12 12
13 public LLSDAssetUploadResponse() 13 public LLSDAssetUploadResponse()
14 { 14 {
15 15
16 } 16 }
17 } 17 }
18} 18}
diff --git a/OpenSim/Region/Capabilities/LLSDCapEvent.cs b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
index 51b4fe0..2c2689b 100644
--- a/OpenSim/Region/Capabilities/LLSDCapEvent.cs
+++ b/OpenSim/Region/Capabilities/LLSDCapEvent.cs
@@ -1,41 +1,41 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Region.Capabilities 28namespace OpenSim.Region.Capabilities
29{ 29{
30 [LLSDType("MAP")] 30 [LLSDType("MAP")]
31 public class LLSDCapEvent 31 public class LLSDCapEvent
32 { 32 {
33 public int id = 0; 33 public int id = 0;
34 public LLSDArray events = new LLSDArray(); 34 public LLSDArray events = new LLSDArray();
35 35
36 public LLSDCapEvent() 36 public LLSDCapEvent()
37 { 37 {
38 38
39 } 39 }
40 } 40 }
41} 41}
diff --git a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
index ecb2328..132b8f7 100644
--- a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
+++ b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs
@@ -1,17 +1,17 @@
1namespace OpenSim.Region.Capabilities 1namespace OpenSim.Region.Capabilities
2{ 2{
3 [LLSDType("MAP")] 3 [LLSDType("MAP")]
4 public class LLSDCapsDetails 4 public class LLSDCapsDetails
5 { 5 {
6 public string MapLayer = ""; 6 public string MapLayer = "";
7 public string NewFileAgentInventory = ""; 7 public string NewFileAgentInventory = "";
8 //public string EventQueueGet = ""; 8 //public string EventQueueGet = "";
9 //public string RequestTextureDownload = ""; 9 //public string RequestTextureDownload = "";
10 //public string ChatSessionRequest = ""; 10 //public string ChatSessionRequest = "";
11 11
12 public LLSDCapsDetails() 12 public LLSDCapsDetails()
13 { 13 {
14 14
15 } 15 }
16 } 16 }
17} 17}
diff --git a/OpenSim/Region/Capabilities/LLSDEmpty.cs b/OpenSim/Region/Capabilities/LLSDEmpty.cs
index d79c09e..ca27c9d 100644
--- a/OpenSim/Region/Capabilities/LLSDEmpty.cs
+++ b/OpenSim/Region/Capabilities/LLSDEmpty.cs
@@ -1,38 +1,38 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Region.Capabilities 28namespace OpenSim.Region.Capabilities
29{ 29{
30 [LLSDType("MAP")] 30 [LLSDType("MAP")]
31 public class LLSDEmpty 31 public class LLSDEmpty
32 { 32 {
33 public LLSDEmpty() 33 public LLSDEmpty()
34 { 34 {
35 35
36 } 36 }
37 } 37 }
38} 38}
diff --git a/OpenSim/Region/Capabilities/LLSDHelpers.cs b/OpenSim/Region/Capabilities/LLSDHelpers.cs
index 19ef0c9..efeb9b1 100644
--- a/OpenSim/Region/Capabilities/LLSDHelpers.cs
+++ b/OpenSim/Region/Capabilities/LLSDHelpers.cs
@@ -1,164 +1,164 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33using libsecondlife; 33using libsecondlife;
34 34
35namespace OpenSim.Region.Capabilities 35namespace OpenSim.Region.Capabilities
36{ 36{
37 public class LLSDHelpers 37 public class LLSDHelpers
38 { 38 {
39 public static string SerialiseLLSDReply(object obj) 39 public static string SerialiseLLSDReply(object obj)
40 { 40 {
41 StringWriter sw = new StringWriter(); 41 StringWriter sw = new StringWriter();
42 XmlTextWriter writer = new XmlTextWriter(sw); 42 XmlTextWriter writer = new XmlTextWriter(sw);
43 writer.Formatting = Formatting.None; 43 writer.Formatting = Formatting.None;
44 writer.WriteStartElement(String.Empty, "llsd", String.Empty); 44 writer.WriteStartElement(String.Empty, "llsd", String.Empty);
45 SerializeLLSDType(writer, obj); 45 SerializeLLSDType(writer, obj);
46 writer.WriteEndElement(); 46 writer.WriteEndElement();
47 writer.Close(); 47 writer.Close();
48 return sw.ToString(); 48 return sw.ToString();
49 } 49 }
50 50
51 public static void SerializeLLSDType(XmlTextWriter writer, object obj) 51 public static void SerializeLLSDType(XmlTextWriter writer, object obj)
52 { 52 {
53 Type myType = obj.GetType(); 53 Type myType = obj.GetType();
54 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); 54 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
55 if (llsdattributes.Length > 0) 55 if (llsdattributes.Length > 0)
56 { 56 {
57 switch (llsdattributes[0].ObjectType) 57 switch (llsdattributes[0].ObjectType)
58 { 58 {
59 case "MAP": 59 case "MAP":
60 writer.WriteStartElement(String.Empty, "map", String.Empty); 60 writer.WriteStartElement(String.Empty, "map", String.Empty);
61 FieldInfo[] fields = myType.GetFields(); 61 FieldInfo[] fields = myType.GetFields();
62 for (int i = 0; i < fields.Length; i++) 62 for (int i = 0; i < fields.Length; i++)
63 { 63 {
64 object fieldValue = fields[i].GetValue(obj); 64 object fieldValue = fields[i].GetValue(obj);
65 LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false); 65 LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
66 if (fieldAttributes.Length > 0) 66 if (fieldAttributes.Length > 0)
67 { 67 {
68 writer.WriteStartElement(String.Empty, "key", String.Empty); 68 writer.WriteStartElement(String.Empty, "key", String.Empty);
69 writer.WriteString(fields[i].Name); 69 writer.WriteString(fields[i].Name);
70 writer.WriteEndElement(); 70 writer.WriteEndElement();
71 SerializeLLSDType(writer, fieldValue); 71 SerializeLLSDType(writer, fieldValue);
72 } 72 }
73 else 73 else
74 { 74 {
75 writer.WriteStartElement(String.Empty, "key", String.Empty); 75 writer.WriteStartElement(String.Empty, "key", String.Empty);
76 writer.WriteString(fields[i].Name); 76 writer.WriteString(fields[i].Name);
77 writer.WriteEndElement(); 77 writer.WriteEndElement();
78 LLSD.LLSDWriteOne(writer, fieldValue); 78 LLSD.LLSDWriteOne(writer, fieldValue);
79 } 79 }
80 } 80 }
81 writer.WriteEndElement(); 81 writer.WriteEndElement();
82 break; 82 break;
83 case "ARRAY": 83 case "ARRAY":
84 // LLSDArray arrayObject = obj as LLSDArray; 84 // LLSDArray arrayObject = obj as LLSDArray;
85 // ArrayList a = arrayObject.Array; 85 // ArrayList a = arrayObject.Array;
86 ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj); 86 ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
87 if (a != null) 87 if (a != null)
88 { 88 {
89 writer.WriteStartElement(String.Empty, "array", String.Empty); 89 writer.WriteStartElement(String.Empty, "array", String.Empty);
90 foreach (object item in a) 90 foreach (object item in a)
91 { 91 {
92 SerializeLLSDType(writer, item); 92 SerializeLLSDType(writer, item);
93 } 93 }
94 writer.WriteEndElement(); 94 writer.WriteEndElement();
95 } 95 }
96 break; 96 break;
97 } 97 }
98 } 98 }
99 else 99 else
100 { 100 {
101 LLSD.LLSDWriteOne(writer, obj); 101 LLSD.LLSDWriteOne(writer, obj);
102 } 102 }
103 } 103 }
104 104
105 public static object DeserialiseLLSDMap(Hashtable llsd, object obj) 105 public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
106 { 106 {
107 Type myType = obj.GetType(); 107 Type myType = obj.GetType();
108 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); 108 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
109 if (llsdattributes.Length > 0) 109 if (llsdattributes.Length > 0)
110 { 110 {
111 switch (llsdattributes[0].ObjectType) 111 switch (llsdattributes[0].ObjectType)
112 { 112 {
113 case "MAP": 113 case "MAP":
114 IDictionaryEnumerator enumerator = llsd.GetEnumerator(); 114 IDictionaryEnumerator enumerator = llsd.GetEnumerator();
115 while (enumerator.MoveNext()) 115 while (enumerator.MoveNext())
116 { 116 {
117 FieldInfo field = myType.GetField((string)enumerator.Key); 117 FieldInfo field = myType.GetField((string)enumerator.Key);
118 if (field != null) 118 if (field != null)
119 { 119 {
120 if (enumerator.Value is Hashtable) 120 if (enumerator.Value is Hashtable)
121 { 121 {
122 object fieldValue = field.GetValue(obj); 122 object fieldValue = field.GetValue(obj);
123 DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); 123 DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue);
124 } 124 }
125 else if (enumerator.Value is ArrayList) 125 else if (enumerator.Value is ArrayList)
126 { 126 {
127 object fieldValue = field.GetValue(obj); 127 object fieldValue = field.GetValue(obj);
128 fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value); 128 fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value);
129 //TODO 129 //TODO
130 // the LLSD map/array types in the array need to be deserialised 130 // the LLSD map/array types in the array need to be deserialised
131 // but first we need to know the right class to deserialise them into. 131 // but first we need to know the right class to deserialise them into.
132 } 132 }
133 else 133 else
134 { 134 {
135 field.SetValue(obj, enumerator.Value); 135 field.SetValue(obj, enumerator.Value);
136 } 136 }
137 } 137 }
138 } 138 }
139 break; 139 break;
140 } 140 }
141 } 141 }
142 return obj; 142 return obj;
143 } 143 }
144 } 144 }
145 145
146 146
147 147
148 148
149 149
150 150
151 151
152 152
153 153
154 154
155 155
156 156
157 157
158 158
159 159
160 160
161 161
162 162
163 163
164} 164}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayer.cs b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
index 566d0e9..e0c006c 100644
--- a/OpenSim/Region/Capabilities/LLSDMapLayer.cs
+++ b/OpenSim/Region/Capabilities/LLSDMapLayer.cs
@@ -1,46 +1,46 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using libsecondlife; 28using libsecondlife;
29 29
30namespace OpenSim.Region.Capabilities 30namespace OpenSim.Region.Capabilities
31{ 31{
32 [LLSDType("MAP")] 32 [LLSDType("MAP")]
33 public class LLSDMapLayer 33 public class LLSDMapLayer
34 { 34 {
35 public int Left = 0; 35 public int Left = 0;
36 public int Right = 0; 36 public int Right = 0;
37 public int Top = 0; 37 public int Top = 0;
38 public int Bottom = 0; 38 public int Bottom = 0;
39 public LLUUID ImageID = LLUUID.Zero; 39 public LLUUID ImageID = LLUUID.Zero;
40 40
41 public LLSDMapLayer() 41 public LLSDMapLayer()
42 { 42 {
43 43
44 } 44 }
45 } 45 }
46} 46}
diff --git a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
index ce746ae..8b9837b 100644
--- a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
+++ b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs
@@ -1,41 +1,41 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Region.Capabilities 28namespace OpenSim.Region.Capabilities
29{ 29{
30 [LLSDType("MAP")] 30 [LLSDType("MAP")]
31 public class LLSDMapLayerResponse 31 public class LLSDMapLayerResponse
32 { 32 {
33 public LLSDMapRequest AgentData = new LLSDMapRequest(); 33 public LLSDMapRequest AgentData = new LLSDMapRequest();
34 public LLSDArray LayerData = new LLSDArray(); 34 public LLSDArray LayerData = new LLSDArray();
35 35
36 public LLSDMapLayerResponse() 36 public LLSDMapLayerResponse()
37 { 37 {
38 38
39 } 39 }
40 } 40 }
41} 41}
diff --git a/OpenSim/Region/Capabilities/LLSDMapRequest.cs b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
index fb739cd..8ac7943 100644
--- a/OpenSim/Region/Capabilities/LLSDMapRequest.cs
+++ b/OpenSim/Region/Capabilities/LLSDMapRequest.cs
@@ -1,13 +1,13 @@
1namespace OpenSim.Region.Capabilities 1namespace OpenSim.Region.Capabilities
2{ 2{
3 [LLSDType("MAP")] 3 [LLSDType("MAP")]
4 public class LLSDMapRequest 4 public class LLSDMapRequest
5 { 5 {
6 public int Flags = 0; 6 public int Flags = 0;
7 7
8 public LLSDMapRequest() 8 public LLSDMapRequest()
9 { 9 {
10 10
11 } 11 }
12 } 12 }
13} 13}
diff --git a/OpenSim/Region/Capabilities/LLSDMethod.cs b/OpenSim/Region/Capabilities/LLSDMethod.cs
index 5f42f44..068d539 100644
--- a/OpenSim/Region/Capabilities/LLSDMethod.cs
+++ b/OpenSim/Region/Capabilities/LLSDMethod.cs
@@ -1,8 +1,8 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Capabilities 5namespace OpenSim.Region.Capabilities
6{ 6{
7 public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request); 7 public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
8} 8}
diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
index 7d99b6e..d98e23f 100644
--- a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
+++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
@@ -1,42 +1,42 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Framework.Servers; 4using OpenSim.Framework.Servers;
5using System.IO; 5using System.IO;
6using System.Collections; 6using System.Collections;
7using libsecondlife; 7using libsecondlife;
8 8
9namespace OpenSim.Region.Capabilities 9namespace OpenSim.Region.Capabilities
10{ 10{
11 public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler 11 public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
12 where TRequest : new() 12 where TRequest : new()
13 { 13 {
14 private LLSDMethod<TRequest, TResponse> m_method; 14 private LLSDMethod<TRequest, TResponse> m_method;
15 15
16 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method) 16 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
17 : base(httpMethod, path ) 17 : base(httpMethod, path )
18 { 18 {
19 m_method = method; 19 m_method = method;
20 } 20 }
21 21
22 public override byte[] Handle(string path, Stream request) 22 public override byte[] Handle(string path, Stream request)
23 { 23 {
24 //Encoding encoding = Encoding.UTF8; 24 //Encoding encoding = Encoding.UTF8;
25 //StreamReader streamReader = new StreamReader(request, false); 25 //StreamReader streamReader = new StreamReader(request, false);
26 26
27 //string requestBody = streamReader.ReadToEnd(); 27 //string requestBody = streamReader.ReadToEnd();
28 //streamReader.Close(); 28 //streamReader.Close();
29 29
30 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); 30 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request );
31 TRequest llsdRequest = new TRequest(); 31 TRequest llsdRequest = new TRequest();
32 LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); 32 LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
33 33
34 TResponse response = m_method(llsdRequest); 34 TResponse response = m_method(llsdRequest);
35 35
36 Encoding encoding = new UTF8Encoding(false); 36 Encoding encoding = new UTF8Encoding(false);
37 37
38 return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); 38 return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
39 39
40 } 40 }
41 } 41 }
42} 42}
diff --git a/OpenSim/Region/Capabilities/LLSDTest.cs b/OpenSim/Region/Capabilities/LLSDTest.cs
index f23e327..78ccf67 100644
--- a/OpenSim/Region/Capabilities/LLSDTest.cs
+++ b/OpenSim/Region/Capabilities/LLSDTest.cs
@@ -1,41 +1,41 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Region.Capabilities 28namespace OpenSim.Region.Capabilities
29{ 29{
30 [LLSDType("MAP")] 30 [LLSDType("MAP")]
31 public class LLSDTest 31 public class LLSDTest
32 { 32 {
33 public int Test1 = 20; 33 public int Test1 = 20;
34 public int Test2 = 10; 34 public int Test2 = 10;
35 35
36 public LLSDTest() 36 public LLSDTest()
37 { 37 {
38 38
39 } 39 }
40 } 40 }
41} 41}
diff --git a/OpenSim/Region/Capabilities/LLSDType.cs b/OpenSim/Region/Capabilities/LLSDType.cs
index c58a937..04f4d9a 100644
--- a/OpenSim/Region/Capabilities/LLSDType.cs
+++ b/OpenSim/Region/Capabilities/LLSDType.cs
@@ -1,59 +1,59 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29 29
30namespace OpenSim.Region.Capabilities 30namespace OpenSim.Region.Capabilities
31{ 31{
32 [AttributeUsage(AttributeTargets.Class)] 32 [AttributeUsage(AttributeTargets.Class)]
33 public class LLSDType : Attribute 33 public class LLSDType : Attribute
34 { 34 {
35 protected string myType; 35 protected string myType;
36 36
37 public LLSDType(string type) 37 public LLSDType(string type)
38 { 38 {
39 myType = type; 39 myType = type;
40 40
41 } 41 }
42 42
43 public string ObjectType 43 public string ObjectType
44 { 44 {
45 get 45 get
46 { 46 {
47 return myType; 47 return myType;
48 } 48 }
49 } 49 }
50 } 50 }
51 51
52 [AttributeUsage(AttributeTargets.Class)] 52 [AttributeUsage(AttributeTargets.Class)]
53 public class LLSDMap : LLSDType 53 public class LLSDMap : LLSDType
54 { 54 {
55 public LLSDMap() : base( "MAP" ) 55 public LLSDMap() : base( "MAP" )
56 { 56 {
57 } 57 }
58 } 58 }
59} 59}
diff --git a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
index e2cfa46..1bb6c07 100644
--- a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
+++ b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
@@ -1,338 +1,338 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Inventory; 35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Region.ClientStack; 37using OpenSim.Region.ClientStack;
38 38
39namespace OpenSim.Assets 39namespace OpenSim.Assets
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// Description of InventoryManager. 42 /// Description of InventoryManager.
43 /// </summary> 43 /// </summary>
44 public class InventoryCache 44 public class InventoryCache
45 { 45 {
46 private Dictionary<LLUUID, AgentInventory> _agentsInventory; 46 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
47 private List<UserServerRequest> _serverRequests; //list of requests made to user server. 47 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
48 private Encoding _enc = Encoding.ASCII; 48 private Encoding _enc = Encoding.ASCII;
49 private const uint FULL_MASK_PERMISSIONS = 2147483647; 49 private const uint FULL_MASK_PERMISSIONS = 2147483647;
50 50
51 public InventoryCache() 51 public InventoryCache()
52 { 52 {
53 _agentsInventory = new Dictionary<LLUUID, AgentInventory>(); 53 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
54 _serverRequests = new List<UserServerRequest>(); 54 _serverRequests = new List<UserServerRequest>();
55 } 55 }
56 56
57 public void AddNewAgentsInventory(AgentInventory agentInventory) 57 public void AddNewAgentsInventory(AgentInventory agentInventory)
58 { 58 {
59 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID)) 59 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID))
60 { 60 {
61 this._agentsInventory.Add(agentInventory.AgentID, agentInventory); 61 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
62 } 62 }
63 } 63 }
64 64
65 public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver) 65 public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver)
66 { 66 {
67 AgentInventory res = null; 67 AgentInventory res = null;
68 if (!this._agentsInventory.ContainsKey(agentID)) 68 if (!this._agentsInventory.ContainsKey(agentID))
69 { 69 {
70 res = userserver.RequestAgentsInventory(agentID); 70 res = userserver.RequestAgentsInventory(agentID);
71 this._agentsInventory.Add(agentID,res); 71 this._agentsInventory.Add(agentID,res);
72 } 72 }
73 return res; 73 return res;
74 } 74 }
75 75
76 public AgentInventory GetAgentsInventory(LLUUID agentID) 76 public AgentInventory GetAgentsInventory(LLUUID agentID)
77 { 77 {
78 if (this._agentsInventory.ContainsKey(agentID)) 78 if (this._agentsInventory.ContainsKey(agentID))
79 { 79 {
80 return this._agentsInventory[agentID]; 80 return this._agentsInventory[agentID];
81 } 81 }
82 82
83 return null; 83 return null;
84 } 84 }
85 85
86 public void ClientLeaving(LLUUID clientID, IUserServer userserver) 86 public void ClientLeaving(LLUUID clientID, IUserServer userserver)
87 { 87 {
88 if (this._agentsInventory.ContainsKey(clientID)) 88 if (this._agentsInventory.ContainsKey(clientID))
89 { 89 {
90 if (userserver != null) 90 if (userserver != null)
91 { 91 {
92 userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]); 92 userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]);
93 } 93 }
94 this._agentsInventory.Remove(clientID); 94 this._agentsInventory.Remove(clientID);
95 } 95 }
96 } 96 }
97 97
98 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID) 98 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
99 { 99 {
100 return this.CreateNewInventoryFolder(remoteClient, folderID, 0); 100 return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
101 } 101 }
102 102
103 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type) 103 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
104 { 104 {
105 bool res = false; 105 bool res = false;
106 if (folderID != LLUUID.Zero) //don't create a folder with a zero id 106 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
107 { 107 {
108 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 108 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
109 { 109 {
110 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type); 110 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type);
111 } 111 }
112 } 112 }
113 return res; 113 return res;
114 } 114 }
115 115
116 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) 116 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
117 { 117 {
118 bool res = false; 118 bool res = false;
119 if (folderID != LLUUID.Zero) //don't create a folder with a zero id 119 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
120 { 120 {
121 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 121 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
122 { 122 {
123 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent); 123 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent);
124 } 124 }
125 } 125 }
126 return res; 126 return res;
127 } 127 }
128 128
129 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset) 129 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset)
130 { 130 {
131 LLUUID newItem = null; 131 LLUUID newItem = null;
132 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 132 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
133 { 133 {
134 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset); 134 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
135 if (newItem != null) 135 if (newItem != null)
136 { 136 {
137 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem]; 137 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem];
138 this.SendItemUpdateCreate(remoteClient, Item); 138 this.SendItemUpdateCreate(remoteClient, Item);
139 } 139 }
140 } 140 }
141 141
142 return newItem; 142 return newItem;
143 } 143 }
144 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID) 144 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
145 { 145 {
146 bool res = false; 146 bool res = false;
147 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 147 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
148 { 148 {
149 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID); 149 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID);
150 if (res) 150 if (res)
151 { 151 {
152 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); 152 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
153 remove.AgentData.AgentID = remoteClient.AgentID; 153 remove.AgentData.AgentID = remoteClient.AgentID;
154 remove.AgentData.SessionID = remoteClient.SessionID; 154 remove.AgentData.SessionID = remoteClient.SessionID;
155 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; 155 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
156 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); 156 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
157 remove.InventoryData[0].ItemID = itemID; 157 remove.InventoryData[0].ItemID = itemID;
158 remoteClient.OutPacket(remove); 158 remoteClient.OutPacket(remove);
159 } 159 }
160 } 160 }
161 161
162 return res; 162 return res;
163 } 163 }
164 164
165 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset) 165 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset)
166 { 166 {
167 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 167 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
168 { 168 {
169 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset); 169 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
170 if (res) 170 if (res)
171 { 171 {
172 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; 172 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
173 this.SendItemUpdateCreate(remoteClient, Item); 173 this.SendItemUpdateCreate(remoteClient, Item);
174 } 174 }
175 return res; 175 return res;
176 } 176 }
177 177
178 return false; 178 return false;
179 } 179 }
180 180
181 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) 181 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
182 { 182 {
183 if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) 183 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
184 { 184 {
185 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet); 185 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
186 if (res) 186 if (res)
187 { 187 {
188 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID]; 188 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
189 this.SendItemUpdateCreate(remoteClient, Item); 189 this.SendItemUpdateCreate(remoteClient, Item);
190 } 190 }
191 return res; 191 return res;
192 } 192 }
193 193
194 return false; 194 return false;
195 } 195 }
196 196
197 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend) 197 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
198 { 198 {
199 199
200 if (this._agentsInventory.ContainsKey(userInfo.AgentID)) 200 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
201 { 201 {
202 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; 202 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
203 if (FetchDescend.InventoryData.FetchItems) 203 if (FetchDescend.InventoryData.FetchItems)
204 { 204 {
205 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID)) 205 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
206 { 206 {
207 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID]; 207 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
208 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); 208 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
209 Descend.AgentData.AgentID = userInfo.AgentID; 209 Descend.AgentData.AgentID = userInfo.AgentID;
210 Descend.AgentData.OwnerID = Folder.OwnerID; 210 Descend.AgentData.OwnerID = Folder.OwnerID;
211 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; 211 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
212 Descend.AgentData.Descendents = Folder.Items.Count; 212 Descend.AgentData.Descendents = Folder.Items.Count;
213 Descend.AgentData.Version = Folder.Items.Count; 213 Descend.AgentData.Version = Folder.Items.Count;
214 214
215 215
216 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; 216 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
217 for (int i = 0; i < Folder.Items.Count; i++) 217 for (int i = 0; i < Folder.Items.Count; i++)
218 { 218 {
219 219
220 InventoryItem Item = Folder.Items[i]; 220 InventoryItem Item = Folder.Items[i];
221 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); 221 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
222 Descend.ItemData[i].ItemID = Item.ItemID; 222 Descend.ItemData[i].ItemID = Item.ItemID;
223 Descend.ItemData[i].AssetID = Item.AssetID; 223 Descend.ItemData[i].AssetID = Item.AssetID;
224 Descend.ItemData[i].CreatorID = Item.CreatorID; 224 Descend.ItemData[i].CreatorID = Item.CreatorID;
225 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; 225 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
226 Descend.ItemData[i].CreationDate = 1000; 226 Descend.ItemData[i].CreationDate = 1000;
227 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0"); 227 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
228 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; 228 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
229 Descend.ItemData[i].Flags = 1; 229 Descend.ItemData[i].Flags = 1;
230 Descend.ItemData[i].FolderID = Item.FolderID; 230 Descend.ItemData[i].FolderID = Item.FolderID;
231 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 231 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
232 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; 232 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
233 Descend.ItemData[i].InvType = Item.InvType; 233 Descend.ItemData[i].InvType = Item.InvType;
234 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0"); 234 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
235 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; 235 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
236 Descend.ItemData[i].OwnerID = Item.OwnerID; 236 Descend.ItemData[i].OwnerID = Item.OwnerID;
237 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; 237 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
238 Descend.ItemData[i].SalePrice = 100; 238 Descend.ItemData[i].SalePrice = 100;
239 Descend.ItemData[i].SaleType = 0; 239 Descend.ItemData[i].SaleType = 0;
240 Descend.ItemData[i].Type = Item.Type; 240 Descend.ItemData[i].Type = Item.Type;
241 Descend.ItemData[i].CRC = 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); 241 Descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
242 } 242 }
243 243
244 userInfo.OutPacket(Descend); 244 userInfo.OutPacket(Descend);
245 245
246 } 246 }
247 } 247 }
248 else 248 else
249 { 249 {
250 Console.WriteLine("fetch subfolders"); 250 Console.WriteLine("fetch subfolders");
251 } 251 }
252 } 252 }
253 } 253 }
254 254
255 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems) 255 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
256 { 256 {
257 if (this._agentsInventory.ContainsKey(userInfo.AgentID)) 257 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
258 { 258 {
259 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; 259 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
260 260
261 for (int i = 0; i < FetchItems.InventoryData.Length; i++) 261 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
262 { 262 {
263 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) 263 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
264 { 264 {
265 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; 265 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
266 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); 266 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
267 InventoryReply.AgentData.AgentID = userInfo.AgentID; 267 InventoryReply.AgentData.AgentID = userInfo.AgentID;
268 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; 268 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
269 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); 269 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
270 InventoryReply.InventoryData[0].ItemID = Item.ItemID; 270 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
271 InventoryReply.InventoryData[0].AssetID = Item.AssetID; 271 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
272 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; 272 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
273 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; 273 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
274 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 274 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
275 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); 275 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
276 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; 276 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
277 InventoryReply.InventoryData[0].Flags = 0; 277 InventoryReply.InventoryData[0].Flags = 0;
278 InventoryReply.InventoryData[0].FolderID = Item.FolderID; 278 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
279 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 279 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
280 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; 280 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
281 InventoryReply.InventoryData[0].InvType = Item.InvType; 281 InventoryReply.InventoryData[0].InvType = Item.InvType;
282 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); 282 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
283 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; 283 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
284 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; 284 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
285 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; 285 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
286 InventoryReply.InventoryData[0].SalePrice = 100; 286 InventoryReply.InventoryData[0].SalePrice = 100;
287 InventoryReply.InventoryData[0].SaleType = 0; 287 InventoryReply.InventoryData[0].SaleType = 0;
288 InventoryReply.InventoryData[0].Type = Item.Type; 288 InventoryReply.InventoryData[0].Type = Item.Type;
289 InventoryReply.InventoryData[0].CRC = 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); 289 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
290 userInfo.OutPacket(InventoryReply); 290 userInfo.OutPacket(InventoryReply);
291 } 291 }
292 } 292 }
293 } 293 }
294 } 294 }
295 295
296 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item) 296 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
297 { 297 {
298 298
299 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); 299 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
300 InventoryReply.AgentData.AgentID = remoteClient.AgentID; 300 InventoryReply.AgentData.AgentID = remoteClient.AgentID;
301 InventoryReply.AgentData.SimApproved = true; 301 InventoryReply.AgentData.SimApproved = true;
302 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; 302 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
303 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); 303 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
304 InventoryReply.InventoryData[0].ItemID = Item.ItemID; 304 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
305 InventoryReply.InventoryData[0].AssetID = Item.AssetID; 305 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
306 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; 306 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
307 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; 307 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
308 InventoryReply.InventoryData[0].CreationDate = 1000; 308 InventoryReply.InventoryData[0].CreationDate = 1000;
309 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); 309 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
310 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; 310 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
311 InventoryReply.InventoryData[0].Flags = 0; 311 InventoryReply.InventoryData[0].Flags = 0;
312 InventoryReply.InventoryData[0].FolderID = Item.FolderID; 312 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
313 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 313 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
314 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; 314 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
315 InventoryReply.InventoryData[0].InvType = Item.InvType; 315 InventoryReply.InventoryData[0].InvType = Item.InvType;
316 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); 316 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
317 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; 317 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
318 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; 318 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
319 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; 319 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
320 InventoryReply.InventoryData[0].SalePrice = 100; 320 InventoryReply.InventoryData[0].SalePrice = 100;
321 InventoryReply.InventoryData[0].SaleType = 0; 321 InventoryReply.InventoryData[0].SaleType = 0;
322 InventoryReply.InventoryData[0].Type = Item.Type; 322 InventoryReply.InventoryData[0].Type = Item.Type;
323 InventoryReply.InventoryData[0].CRC = 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); 323 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
324 324
325 remoteClient.OutPacket(InventoryReply); 325 remoteClient.OutPacket(InventoryReply);
326 } 326 }
327 } 327 }
328 328
329 329
330 330
331 public class UserServerRequest 331 public class UserServerRequest
332 { 332 {
333 public UserServerRequest() 333 public UserServerRequest()
334 { 334 {
335 335
336 } 336 }
337 } 337 }
338} 338}
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
index f4e537c..e3ad9d0 100644
--- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
+++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
@@ -1,40 +1,40 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Net.Sockets; 28using System.Net.Sockets;
29 29
30namespace OpenSim.Region.ClientStack 30namespace OpenSim.Region.ClientStack
31{ 31{
32 32
33 public interface ClientStackNetworkHandler 33 public interface ClientStackNetworkHandler
34 { 34 {
35 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); 35 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
36 void RemoveClientCircuit(uint circuitcode); 36 void RemoveClientCircuit(uint circuitcode);
37 void RegisterPacketServer(PacketServer server); 37 void RegisterPacketServer(PacketServer server);
38 } 38 }
39 39
40} 40}
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index 33e34c1..2ac1000 100644
--- a/OpenSim/Region/ClientStack/ClientView.API.cs
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -1,1180 +1,1180 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Text; 31using System.Text;
32using Axiom.Math; 32using Axiom.Math;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.Packets; 34using libsecondlife.Packets;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types; 37using OpenSim.Framework.Types;
38using OpenSim.Framework.Data; 38using OpenSim.Framework.Data;
39 39
40namespace OpenSim.Region.ClientStack 40namespace OpenSim.Region.ClientStack
41{ 41{
42 partial class ClientView 42 partial class ClientView
43 { 43 {
44 public event ImprovedInstantMessage OnInstantMessage; 44 public event ImprovedInstantMessage OnInstantMessage;
45 public event ChatFromViewer OnChatFromViewer; 45 public event ChatFromViewer OnChatFromViewer;
46 public event RezObject OnRezObject; 46 public event RezObject OnRezObject;
47 public event GenericCall4 OnDeRezObject; 47 public event GenericCall4 OnDeRezObject;
48 public event ModifyTerrain OnModifyTerrain; 48 public event ModifyTerrain OnModifyTerrain;
49 public event GenericCall OnRegionHandShakeReply; 49 public event GenericCall OnRegionHandShakeReply;
50 public event GenericCall OnRequestWearables; 50 public event GenericCall OnRequestWearables;
51 public event SetAppearance OnSetAppearance; 51 public event SetAppearance OnSetAppearance;
52 public event GenericCall2 OnCompleteMovementToRegion; 52 public event GenericCall2 OnCompleteMovementToRegion;
53 public event UpdateAgent OnAgentUpdate; 53 public event UpdateAgent OnAgentUpdate;
54 public event StartAnim OnStartAnim; 54 public event StartAnim OnStartAnim;
55 public event GenericCall OnRequestAvatarsData; 55 public event GenericCall OnRequestAvatarsData;
56 public event LinkObjects OnLinkObjects; 56 public event LinkObjects OnLinkObjects;
57 public event UpdateVector OnGrapObject; 57 public event UpdateVector OnGrapObject;
58 public event ObjectSelect OnDeGrapObject; 58 public event ObjectSelect OnDeGrapObject;
59 public event ObjectDuplicate OnObjectDuplicate; 59 public event ObjectDuplicate OnObjectDuplicate;
60 public event MoveObject OnGrapUpdate; 60 public event MoveObject OnGrapUpdate;
61 public event AddNewPrim OnAddPrim; 61 public event AddNewPrim OnAddPrim;
62 public event UpdateShape OnUpdatePrimShape; 62 public event UpdateShape OnUpdatePrimShape;
63 public event ObjectSelect OnObjectSelect; 63 public event ObjectSelect OnObjectSelect;
64 public event ObjectDeselect OnObjectDeselect; 64 public event ObjectDeselect OnObjectDeselect;
65 public event GenericCall7 OnObjectDescription; 65 public event GenericCall7 OnObjectDescription;
66 public event GenericCall7 OnObjectName; 66 public event GenericCall7 OnObjectName;
67 public event UpdatePrimFlags OnUpdatePrimFlags; 67 public event UpdatePrimFlags OnUpdatePrimFlags;
68 public event UpdatePrimTexture OnUpdatePrimTexture; 68 public event UpdatePrimTexture OnUpdatePrimTexture;
69 public event UpdateVector OnUpdatePrimGroupPosition; 69 public event UpdateVector OnUpdatePrimGroupPosition;
70 public event UpdateVector OnUpdatePrimSinglePosition; 70 public event UpdateVector OnUpdatePrimSinglePosition;
71 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 71 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
72 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 72 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
73 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; 73 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
74 public event UpdateVector OnUpdatePrimScale; 74 public event UpdateVector OnUpdatePrimScale;
75 public event StatusChange OnChildAgentStatus; 75 public event StatusChange OnChildAgentStatus;
76 public event GenericCall2 OnStopMovement; 76 public event GenericCall2 OnStopMovement;
77 public event NewAvatar OnNewAvatar; 77 public event NewAvatar OnNewAvatar;
78 public event GenericCall6 OnRemoveAvatar; 78 public event GenericCall6 OnRemoveAvatar;
79 public event RequestMapBlocks OnRequestMapBlocks; 79 public event RequestMapBlocks OnRequestMapBlocks;
80 public event TeleportLocationRequest OnTeleportLocationRequest; 80 public event TeleportLocationRequest OnTeleportLocationRequest;
81 81
82 public event UUIDNameRequest OnNameFromUUIDRequest; 82 public event UUIDNameRequest OnNameFromUUIDRequest;
83 83
84 public event ParcelPropertiesRequest OnParcelPropertiesRequest; 84 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
85 public event ParcelDivideRequest OnParcelDivideRequest; 85 public event ParcelDivideRequest OnParcelDivideRequest;
86 public event ParcelJoinRequest OnParcelJoinRequest; 86 public event ParcelJoinRequest OnParcelJoinRequest;
87 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; 87 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
88 public event ParcelSelectObjects OnParcelSelectObjects; 88 public event ParcelSelectObjects OnParcelSelectObjects;
89 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; 89 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
90 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 90 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
91 91
92 /// <summary> 92 /// <summary>
93 /// 93 ///
94 /// </summary> 94 /// </summary>
95 public LLVector3 StartPos 95 public LLVector3 StartPos
96 { 96 {
97 get 97 get
98 { 98 {
99 return startpos; 99 return startpos;
100 } 100 }
101 set 101 set
102 { 102 {
103 startpos = value; 103 startpos = value;
104 } 104 }
105 } 105 }
106 106
107 /// <summary> 107 /// <summary>
108 /// 108 ///
109 /// </summary> 109 /// </summary>
110 public LLUUID AgentId 110 public LLUUID AgentId
111 { 111 {
112 get 112 get
113 { 113 {
114 return this.AgentID; 114 return this.AgentID;
115 } 115 }
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// 119 ///
120 /// </summary> 120 /// </summary>
121 public string FirstName 121 public string FirstName
122 { 122 {
123 get 123 get
124 { 124 {
125 return this.firstName; 125 return this.firstName;
126 } 126 }
127 127
128 } 128 }
129 129
130 /// <summary> 130 /// <summary>
131 /// 131 ///
132 /// </summary> 132 /// </summary>
133 public string LastName 133 public string LastName
134 { 134 {
135 get 135 get
136 { 136 {
137 return this.lastName; 137 return this.lastName;
138 } 138 }
139 } 139 }
140 140
141 #region World/Avatar to Client 141 #region World/Avatar to Client
142 142
143 /// <summary> 143 /// <summary>
144 /// 144 ///
145 /// </summary> 145 /// </summary>
146 /// <param name="regionInfo"></param> 146 /// <param name="regionInfo"></param>
147 public void SendRegionHandshake(RegionInfo regionInfo) 147 public void SendRegionHandshake(RegionInfo regionInfo)
148 { 148 {
149 Encoding _enc = Encoding.ASCII; 149 Encoding _enc = Encoding.ASCII;
150 RegionHandshakePacket handshake = new RegionHandshakePacket(); 150 RegionHandshakePacket handshake = new RegionHandshakePacket();
151 151
152 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor; 152 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor;
153 handshake.RegionInfo.IsEstateManager = false; 153 handshake.RegionInfo.IsEstateManager = false;
154 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0; 154 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0;
155 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1; 155 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1;
156 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2; 156 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2;
157 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3; 157 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3;
158 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0; 158 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0;
159 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1; 159 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1;
160 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2; 160 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2;
161 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3; 161 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3;
162 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess; 162 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess;
163 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight; 163 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight;
164 164
165 165
166 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags; 166 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags;
167 167
168 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); 168 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
169 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; 169 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
170 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0; 170 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0;
171 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1; 171 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1;
172 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2; 172 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2;
173 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3; 173 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3;
174 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0; 174 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0;
175 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1; 175 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1;
176 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2; 176 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2;
177 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3; 177 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3;
178 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? 178 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
179 179
180 this.OutPacket(handshake); 180 this.OutPacket(handshake);
181 } 181 }
182 182
183 /// <summary> 183 /// <summary>
184 /// 184 ///
185 /// </summary> 185 /// </summary>
186 /// <param name="regInfo"></param> 186 /// <param name="regInfo"></param>
187 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) 187 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
188 { 188 {
189 AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); 189 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
190 mov.AgentData.SessionID = this.SessionID; 190 mov.AgentData.SessionID = this.SessionID;
191 mov.AgentData.AgentID = this.AgentID; 191 mov.AgentData.AgentID = this.AgentID;
192 mov.Data.RegionHandle = regInfo.RegionHandle; 192 mov.Data.RegionHandle = regInfo.RegionHandle;
193 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this 193 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
194 194
195 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) 195 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
196 { 196 {
197 mov.Data.Position = this.startpos; 197 mov.Data.Position = this.startpos;
198 } 198 }
199 else 199 else
200 { 200 {
201 mov.Data.Position = pos; 201 mov.Data.Position = pos;
202 } 202 }
203 mov.Data.LookAt = look; 203 mov.Data.LookAt = look;
204 204
205 OutPacket(mov); 205 OutPacket(mov);
206 } 206 }
207 207
208 /// <summary> 208 /// <summary>
209 /// 209 ///
210 /// </summary> 210 /// </summary>
211 /// <param name="message"></param> 211 /// <param name="message"></param>
212 /// <param name="type"></param> 212 /// <param name="type"></param>
213 /// <param name="fromPos"></param> 213 /// <param name="fromPos"></param>
214 /// <param name="fromName"></param> 214 /// <param name="fromName"></param>
215 /// <param name="fromAgentID"></param> 215 /// <param name="fromAgentID"></param>
216 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 216 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
217 { 217 {
218 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); 218 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
219 } 219 }
220 220
221 /// <summary> 221 /// <summary>
222 /// 222 ///
223 /// </summary> 223 /// </summary>
224 /// <param name="message"></param> 224 /// <param name="message"></param>
225 /// <param name="type"></param> 225 /// <param name="type"></param>
226 /// <param name="fromPos"></param> 226 /// <param name="fromPos"></param>
227 /// <param name="fromName"></param> 227 /// <param name="fromName"></param>
228 /// <param name="fromAgentID"></param> 228 /// <param name="fromAgentID"></param>
229 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 229 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
230 { 230 {
231 Encoding enc = Encoding.ASCII; 231 Encoding enc = Encoding.ASCII;
232 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); 232 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
233 reply.ChatData.Audible = 1; 233 reply.ChatData.Audible = 1;
234 reply.ChatData.Message = message; 234 reply.ChatData.Message = message;
235 reply.ChatData.ChatType = type; 235 reply.ChatData.ChatType = type;
236 reply.ChatData.SourceType = 1; 236 reply.ChatData.SourceType = 1;
237 reply.ChatData.Position = fromPos; 237 reply.ChatData.Position = fromPos;
238 reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); 238 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
239 reply.ChatData.OwnerID = fromAgentID; 239 reply.ChatData.OwnerID = fromAgentID;
240 reply.ChatData.SourceID = fromAgentID; 240 reply.ChatData.SourceID = fromAgentID;
241 241
242 this.OutPacket(reply); 242 this.OutPacket(reply);
243 } 243 }
244 244
245 /// <summary> 245 /// <summary>
246 /// 246 ///
247 /// </summary> 247 /// </summary>
248 /// <remarks>TODO</remarks> 248 /// <remarks>TODO</remarks>
249 /// <param name="message"></param> 249 /// <param name="message"></param>
250 /// <param name="target"></param> 250 /// <param name="target"></param>
251 public void SendInstantMessage(string message, LLUUID target, string fromName) 251 public void SendInstantMessage(string message, LLUUID target, string fromName)
252 { 252 {
253 if (message != "typing") 253 if (message != "typing")
254 { 254 {
255 Encoding enc = Encoding.ASCII; 255 Encoding enc = Encoding.ASCII;
256 ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); 256 ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket();
257 msg.AgentData.AgentID = this.AgentID; 257 msg.AgentData.AgentID = this.AgentID;
258 msg.AgentData.SessionID = this.SessionID; 258 msg.AgentData.SessionID = this.SessionID;
259 msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); 259 msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0");
260 msg.MessageBlock.Dialog = 0; 260 msg.MessageBlock.Dialog = 0;
261 msg.MessageBlock.FromGroup = false; 261 msg.MessageBlock.FromGroup = false;
262 msg.MessageBlock.ID = target.Combine(this.SecureSessionID); 262 msg.MessageBlock.ID = target.Combine(this.SecureSessionID);
263 msg.MessageBlock.Offline = 0; 263 msg.MessageBlock.Offline = 0;
264 msg.MessageBlock.ParentEstateID = 0; 264 msg.MessageBlock.ParentEstateID = 0;
265 msg.MessageBlock.Position = new LLVector3(); 265 msg.MessageBlock.Position = new LLVector3();
266 msg.MessageBlock.RegionID = new LLUUID(); 266 msg.MessageBlock.RegionID = new LLUUID();
267 msg.MessageBlock.Timestamp = 0; 267 msg.MessageBlock.Timestamp = 0;
268 msg.MessageBlock.ToAgentID = target; 268 msg.MessageBlock.ToAgentID = target;
269 msg.MessageBlock.Message = enc.GetBytes(message + "\0"); 269 msg.MessageBlock.Message = enc.GetBytes(message + "\0");
270 msg.MessageBlock.BinaryBucket = new byte[0]; 270 msg.MessageBlock.BinaryBucket = new byte[0];
271 271
272 this.OutPacket(msg); 272 this.OutPacket(msg);
273 } 273 }
274 } 274 }
275 275
276 /// <summary> 276 /// <summary>
277 /// Send the region heightmap to the client 277 /// Send the region heightmap to the client
278 /// </summary> 278 /// </summary>
279 /// <param name="map">heightmap</param> 279 /// <param name="map">heightmap</param>
280 public virtual void SendLayerData(float[] map) 280 public virtual void SendLayerData(float[] map)
281 { 281 {
282 try 282 try
283 { 283 {
284 int[] patches = new int[4]; 284 int[] patches = new int[4];
285 285
286 for (int y = 0; y < 16; y++) 286 for (int y = 0; y < 16; y++)
287 { 287 {
288 for (int x = 0; x < 16; x = x + 4) 288 for (int x = 0; x < 16; x = x + 4)
289 { 289 {
290 patches[0] = x + 0 + y * 16; 290 patches[0] = x + 0 + y * 16;
291 patches[1] = x + 1 + y * 16; 291 patches[1] = x + 1 + y * 16;
292 patches[2] = x + 2 + y * 16; 292 patches[2] = x + 2 + y * 16;
293 patches[3] = x + 3 + y * 16; 293 patches[3] = x + 3 + y * 16;
294 294
295 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 295 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
296 OutPacket(layerpack); 296 OutPacket(layerpack);
297 } 297 }
298 } 298 }
299 } 299 }
300 catch (Exception e) 300 catch (Exception e)
301 { 301 {
302 MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); 302 MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
303 } 303 }
304 } 304 }
305 305
306 /// <summary> 306 /// <summary>
307 /// Sends a specified patch to a client 307 /// Sends a specified patch to a client
308 /// </summary> 308 /// </summary>
309 /// <param name="px">Patch coordinate (x) 0..16</param> 309 /// <param name="px">Patch coordinate (x) 0..16</param>
310 /// <param name="py">Patch coordinate (y) 0..16</param> 310 /// <param name="py">Patch coordinate (y) 0..16</param>
311 /// <param name="map">heightmap</param> 311 /// <param name="map">heightmap</param>
312 public void SendLayerData(int px, int py, float[] map) 312 public void SendLayerData(int px, int py, float[] map)
313 { 313 {
314 try 314 try
315 { 315 {
316 int[] patches = new int[1]; 316 int[] patches = new int[1];
317 int patchx, patchy; 317 int patchx, patchy;
318 patchx = px / 16; 318 patchx = px / 16;
319 patchy = py / 16; 319 patchy = py / 16;
320 320
321 patches[0] = patchx + 0 + patchy * 16; 321 patches[0] = patchx + 0 + patchy * 16;
322 322
323 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 323 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
324 OutPacket(layerpack); 324 OutPacket(layerpack);
325 } 325 }
326 catch (Exception e) 326 catch (Exception e)
327 { 327 {
328 MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); 328 MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
329 } 329 }
330 } 330 }
331 331
332 /// <summary> 332 /// <summary>
333 /// 333 ///
334 /// </summary> 334 /// </summary>
335 /// <param name="neighbourHandle"></param> 335 /// <param name="neighbourHandle"></param>
336 /// <param name="neighbourIP"></param> 336 /// <param name="neighbourIP"></param>
337 /// <param name="neighbourPort"></param> 337 /// <param name="neighbourPort"></param>
338 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) 338 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
339 { 339 {
340 IPAddress neighbourIP = neighbourEndPoint.Address; 340 IPAddress neighbourIP = neighbourEndPoint.Address;
341 ushort neighbourPort = (ushort)neighbourEndPoint.Port; 341 ushort neighbourPort = (ushort)neighbourEndPoint.Port;
342 342
343 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); 343 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
344 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); 344 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
345 enablesimpacket.SimulatorInfo.Handle = neighbourHandle; 345 enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
346 346
347 byte[] byteIP = neighbourIP.GetAddressBytes(); 347 byte[] byteIP = neighbourIP.GetAddressBytes();
348 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; 348 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
349 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; 349 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
350 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; 350 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
351 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; 351 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
352 enablesimpacket.SimulatorInfo.Port = neighbourPort; 352 enablesimpacket.SimulatorInfo.Port = neighbourPort;
353 OutPacket(enablesimpacket); 353 OutPacket(enablesimpacket);
354 } 354 }
355 355
356 /// <summary> 356 /// <summary>
357 /// 357 ///
358 /// </summary> 358 /// </summary>
359 /// <returns></returns> 359 /// <returns></returns>
360 public AgentCircuitData RequestClientInfo() 360 public AgentCircuitData RequestClientInfo()
361 { 361 {
362 AgentCircuitData agentData = new AgentCircuitData(); 362 AgentCircuitData agentData = new AgentCircuitData();
363 agentData.AgentID = this.AgentId; 363 agentData.AgentID = this.AgentId;
364 agentData.SessionID = this.SessionID; 364 agentData.SessionID = this.SessionID;
365 agentData.SecureSessionID = this.SecureSessionID; 365 agentData.SecureSessionID = this.SecureSessionID;
366 agentData.circuitcode = this.CircuitCode; 366 agentData.circuitcode = this.CircuitCode;
367 agentData.child = false; 367 agentData.child = false;
368 agentData.firstname = this.firstName; 368 agentData.firstname = this.firstName;
369 agentData.lastname = this.lastName; 369 agentData.lastname = this.lastName;
370 370
371 return agentData; 371 return agentData;
372 } 372 }
373 373
374 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint) 374 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint)
375 { 375 {
376 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); 376 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
377 377
378 CrossedRegionPacket newSimPack = new CrossedRegionPacket(); 378 CrossedRegionPacket newSimPack = new CrossedRegionPacket();
379 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); 379 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
380 newSimPack.AgentData.AgentID = this.AgentID; 380 newSimPack.AgentData.AgentID = this.AgentID;
381 newSimPack.AgentData.SessionID = this.SessionID; 381 newSimPack.AgentData.SessionID = this.SessionID;
382 newSimPack.Info = new CrossedRegionPacket.InfoBlock(); 382 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
383 newSimPack.Info.Position = pos; 383 newSimPack.Info.Position = pos;
384 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! 384 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
385 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); 385 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
386 newSimPack.RegionData.RegionHandle = newRegionHandle; 386 newSimPack.RegionData.RegionHandle = newRegionHandle;
387 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); 387 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
388 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; 388 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
389 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; 389 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
390 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; 390 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
391 newSimPack.RegionData.SimIP += (uint)byteIP[0]; 391 newSimPack.RegionData.SimIP += (uint)byteIP[0];
392 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; 392 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
393 newSimPack.RegionData.SeedCapability = new byte[0]; 393 newSimPack.RegionData.SeedCapability = new byte[0];
394 394
395 this.OutPacket(newSimPack); 395 this.OutPacket(newSimPack);
396 //this.DowngradeClient(); 396 //this.DowngradeClient();
397 } 397 }
398 398
399 public void SendMapBlock(List<MapBlockData> mapBlocks) 399 public void SendMapBlock(List<MapBlockData> mapBlocks)
400 { 400 {
401 MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); 401 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
402 mapReply.AgentData.AgentID = this.AgentID; 402 mapReply.AgentData.AgentID = this.AgentID;
403 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; 403 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
404 mapReply.AgentData.Flags = 0; 404 mapReply.AgentData.Flags = 0;
405 405
406 for (int i = 0; i < mapBlocks.Count; i++) 406 for (int i = 0; i < mapBlocks.Count; i++)
407 { 407 {
408 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); 408 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
409 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; 409 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
410 mapReply.Data[i].X = mapBlocks[i].X; 410 mapReply.Data[i].X = mapBlocks[i].X;
411 mapReply.Data[i].Y = mapBlocks[i].Y; 411 mapReply.Data[i].Y = mapBlocks[i].Y;
412 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; 412 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
413 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); 413 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name);
414 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; 414 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
415 mapReply.Data[i].Access = mapBlocks[i].Access; 415 mapReply.Data[i].Access = mapBlocks[i].Access;
416 mapReply.Data[i].Agents = mapBlocks[i].Agents; 416 mapReply.Data[i].Agents = mapBlocks[i].Agents;
417 } 417 }
418 this.OutPacket(mapReply); 418 this.OutPacket(mapReply);
419 } 419 }
420 420
421 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) 421 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
422 { 422 {
423 TeleportLocalPacket tpLocal = new TeleportLocalPacket(); 423 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
424 tpLocal.Info.AgentID = this.AgentID; 424 tpLocal.Info.AgentID = this.AgentID;
425 tpLocal.Info.TeleportFlags = flags; 425 tpLocal.Info.TeleportFlags = flags;
426 tpLocal.Info.LocationID = 2; 426 tpLocal.Info.LocationID = 2;
427 tpLocal.Info.LookAt = lookAt; 427 tpLocal.Info.LookAt = lookAt;
428 tpLocal.Info.Position = position; 428 tpLocal.Info.Position = position;
429 OutPacket(tpLocal); 429 OutPacket(tpLocal);
430 } 430 }
431 431
432 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags) 432 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags)
433 { 433 {
434 TeleportFinishPacket teleport = new TeleportFinishPacket(); 434 TeleportFinishPacket teleport = new TeleportFinishPacket();
435 teleport.Info.AgentID = this.AgentID; 435 teleport.Info.AgentID = this.AgentID;
436 teleport.Info.RegionHandle = regionHandle; 436 teleport.Info.RegionHandle = regionHandle;
437 teleport.Info.SimAccess = simAccess; 437 teleport.Info.SimAccess = simAccess;
438 teleport.Info.SeedCapability = new byte[0]; 438 teleport.Info.SeedCapability = new byte[0];
439 439
440 IPAddress oIP = newRegionEndPoint.Address; 440 IPAddress oIP = newRegionEndPoint.Address;
441 byte[] byteIP = oIP.GetAddressBytes(); 441 byte[] byteIP = oIP.GetAddressBytes();
442 uint ip = (uint)byteIP[3] << 24; 442 uint ip = (uint)byteIP[3] << 24;
443 ip += (uint)byteIP[2] << 16; 443 ip += (uint)byteIP[2] << 16;
444 ip += (uint)byteIP[1] << 8; 444 ip += (uint)byteIP[1] << 8;
445 ip += (uint)byteIP[0]; 445 ip += (uint)byteIP[0];
446 446
447 teleport.Info.SimIP = ip; 447 teleport.Info.SimIP = ip;
448 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; 448 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
449 teleport.Info.LocationID = 4; 449 teleport.Info.LocationID = 4;
450 teleport.Info.TeleportFlags = 1 << 4; 450 teleport.Info.TeleportFlags = 1 << 4;
451 OutPacket(teleport); 451 OutPacket(teleport);
452 } 452 }
453 453
454 /// <summary> 454 /// <summary>
455 /// 455 ///
456 /// </summary> 456 /// </summary>
457 public void SendTeleportCancel() 457 public void SendTeleportCancel()
458 { 458 {
459 TeleportCancelPacket tpCancel = new TeleportCancelPacket(); 459 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
460 tpCancel.Info.SessionID = this.SessionID; 460 tpCancel.Info.SessionID = this.SessionID;
461 tpCancel.Info.AgentID = this.AgentID; 461 tpCancel.Info.AgentID = this.AgentID;
462 462
463 OutPacket(tpCancel); 463 OutPacket(tpCancel);
464 } 464 }
465 465
466 /// <summary> 466 /// <summary>
467 /// 467 ///
468 /// </summary> 468 /// </summary>
469 public void SendTeleportLocationStart() 469 public void SendTeleportLocationStart()
470 { 470 {
471 TeleportStartPacket tpStart = new TeleportStartPacket(); 471 TeleportStartPacket tpStart = new TeleportStartPacket();
472 tpStart.Info.TeleportFlags = 16; // Teleport via location 472 tpStart.Info.TeleportFlags = 16; // Teleport via location
473 OutPacket(tpStart); 473 OutPacket(tpStart);
474 } 474 }
475 475
476 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) 476 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
477 { 477 {
478 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); 478 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
479 money.MoneyData.AgentID = this.AgentID; 479 money.MoneyData.AgentID = this.AgentID;
480 money.MoneyData.TransactionID = transaction; 480 money.MoneyData.TransactionID = transaction;
481 money.MoneyData.TransactionSuccess = success; 481 money.MoneyData.TransactionSuccess = success;
482 money.MoneyData.Description = description; 482 money.MoneyData.Description = description;
483 money.MoneyData.MoneyBalance = balance; 483 money.MoneyData.MoneyBalance = balance;
484 OutPacket(money); 484 OutPacket(money);
485 } 485 }
486 486
487 public void SendStartPingCheck(byte seq) 487 public void SendStartPingCheck(byte seq)
488 { 488 {
489 StartPingCheckPacket pc = new StartPingCheckPacket(); 489 StartPingCheckPacket pc = new StartPingCheckPacket();
490 pc.PingID.PingID = seq; 490 pc.PingID.PingID = seq;
491 OutPacket(pc); 491 OutPacket(pc);
492 } 492 }
493 493
494 public void SendKillObject(ulong regionHandle, uint avatarLocalID) 494 public void SendKillObject(ulong regionHandle, uint avatarLocalID)
495 { 495 {
496 KillObjectPacket kill = new KillObjectPacket(); 496 KillObjectPacket kill = new KillObjectPacket();
497 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 497 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
498 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 498 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
499 kill.ObjectData[0].ID = avatarLocalID; 499 kill.ObjectData[0].ID = avatarLocalID;
500 OutPacket(kill); 500 OutPacket(kill);
501 } 501 }
502 502
503 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) 503 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items)
504 { 504 {
505 Encoding enc = Encoding.ASCII; 505 Encoding enc = Encoding.ASCII;
506 uint FULL_MASK_PERMISSIONS = 2147483647; 506 uint FULL_MASK_PERMISSIONS = 2147483647;
507 InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); 507 InventoryDescendentsPacket descend = new InventoryDescendentsPacket();
508 descend.AgentData.AgentID = this.AgentId; 508 descend.AgentData.AgentID = this.AgentId;
509 descend.AgentData.OwnerID = ownerID; 509 descend.AgentData.OwnerID = ownerID;
510 descend.AgentData.FolderID = folderID; 510 descend.AgentData.FolderID = folderID;
511 descend.AgentData.Descendents = items.Count; 511 descend.AgentData.Descendents = items.Count;
512 descend.AgentData.Version = 0; 512 descend.AgentData.Version = 0;
513 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; 513 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
514 int i = 0; 514 int i = 0;
515 foreach (InventoryItemBase item in items) 515 foreach (InventoryItemBase item in items)
516 { 516 {
517 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); 517 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
518 descend.ItemData[i].ItemID = item.inventoryID; 518 descend.ItemData[i].ItemID = item.inventoryID;
519 descend.ItemData[i].AssetID = item.assetID; 519 descend.ItemData[i].AssetID = item.assetID;
520 descend.ItemData[i].CreatorID = item.creatorsID; 520 descend.ItemData[i].CreatorID = item.creatorsID;
521 descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; 521 descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
522 descend.ItemData[i].CreationDate = 1000; 522 descend.ItemData[i].CreationDate = 1000;
523 descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0"); 523 descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0");
524 descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; 524 descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
525 descend.ItemData[i].Flags = 1; 525 descend.ItemData[i].Flags = 1;
526 descend.ItemData[i].FolderID = item.parentFolderID; 526 descend.ItemData[i].FolderID = item.parentFolderID;
527 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 527 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
528 descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; 528 descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
529 descend.ItemData[i].InvType = (sbyte)item.type; 529 descend.ItemData[i].InvType = (sbyte)item.type;
530 descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0"); 530 descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0");
531 descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; 531 descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
532 descend.ItemData[i].OwnerID = item.avatarID; 532 descend.ItemData[i].OwnerID = item.avatarID;
533 descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; 533 descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
534 descend.ItemData[i].SalePrice = 0; 534 descend.ItemData[i].SalePrice = 0;
535 descend.ItemData[i].SaleType = 0; 535 descend.ItemData[i].SaleType = 0;
536 descend.ItemData[i].Type = (sbyte)item.type; 536 descend.ItemData[i].Type = (sbyte)item.type;
537 descend.ItemData[i].CRC = 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); 537 descend.ItemData[i].CRC = 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);
538 538
539 i++; 539 i++;
540 } 540 }
541 541
542 this.OutPacket(descend); 542 this.OutPacket(descend);
543 543
544 } 544 }
545 545
546 public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) 546 public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item)
547 { 547 {
548 Encoding enc = Encoding.ASCII; 548 Encoding enc = Encoding.ASCII;
549 uint FULL_MASK_PERMISSIONS = 2147483647; 549 uint FULL_MASK_PERMISSIONS = 2147483647;
550 FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); 550 FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket();
551 inventoryReply.AgentData.AgentID = this.AgentId; 551 inventoryReply.AgentData.AgentID = this.AgentId;
552 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; 552 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
553 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); 553 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
554 inventoryReply.InventoryData[0].ItemID = item.inventoryID; 554 inventoryReply.InventoryData[0].ItemID = item.inventoryID;
555 inventoryReply.InventoryData[0].AssetID = item.assetID; 555 inventoryReply.InventoryData[0].AssetID = item.assetID;
556 inventoryReply.InventoryData[0].CreatorID = item.creatorsID; 556 inventoryReply.InventoryData[0].CreatorID = item.creatorsID;
557 inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; 557 inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
558 inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 558 inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
559 inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); 559 inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0");
560 inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; 560 inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
561 inventoryReply.InventoryData[0].Flags = 0; 561 inventoryReply.InventoryData[0].Flags = 0;
562 inventoryReply.InventoryData[0].FolderID = item.parentFolderID; 562 inventoryReply.InventoryData[0].FolderID = item.parentFolderID;
563 inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 563 inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
564 inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; 564 inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
565 inventoryReply.InventoryData[0].InvType = (sbyte)item.type; 565 inventoryReply.InventoryData[0].InvType = (sbyte)item.type;
566 inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); 566 inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0");
567 inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; 567 inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
568 inventoryReply.InventoryData[0].OwnerID = item.avatarID; 568 inventoryReply.InventoryData[0].OwnerID = item.avatarID;
569 inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; 569 inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
570 inventoryReply.InventoryData[0].SalePrice = 0; 570 inventoryReply.InventoryData[0].SalePrice = 0;
571 inventoryReply.InventoryData[0].SaleType = 0; 571 inventoryReply.InventoryData[0].SaleType = 0;
572 inventoryReply.InventoryData[0].Type = (sbyte)item.type; 572 inventoryReply.InventoryData[0].Type = (sbyte)item.type;
573 inventoryReply.InventoryData[0].CRC = 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); 573 inventoryReply.InventoryData[0].CRC = 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);
574 574
575 this.OutPacket(inventoryReply); 575 this.OutPacket(inventoryReply);
576 } 576 }
577 577
578 #region Appearance/ Wearables Methods 578 #region Appearance/ Wearables Methods
579 579
580 /// <summary> 580 /// <summary>
581 /// 581 ///
582 /// </summary> 582 /// </summary>
583 /// <param name="wearables"></param> 583 /// <param name="wearables"></param>
584 public void SendWearables(AvatarWearable[] wearables) 584 public void SendWearables(AvatarWearable[] wearables)
585 { 585 {
586 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); 586 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
587 aw.AgentData.AgentID = this.AgentID; 587 aw.AgentData.AgentID = this.AgentID;
588 aw.AgentData.SerialNum = 0; 588 aw.AgentData.SerialNum = 0;
589 aw.AgentData.SessionID = this.SessionID; 589 aw.AgentData.SessionID = this.SessionID;
590 590
591 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; 591 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
592 AgentWearablesUpdatePacket.WearableDataBlock awb; 592 AgentWearablesUpdatePacket.WearableDataBlock awb;
593 for (int i = 0; i < wearables.Length; i++) 593 for (int i = 0; i < wearables.Length; i++)
594 { 594 {
595 awb = new AgentWearablesUpdatePacket.WearableDataBlock(); 595 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
596 awb.WearableType = (byte)i; 596 awb.WearableType = (byte)i;
597 awb.AssetID = wearables[i].AssetID; 597 awb.AssetID = wearables[i].AssetID;
598 awb.ItemID = wearables[i].ItemID; 598 awb.ItemID = wearables[i].ItemID;
599 aw.WearableData[i] = awb; 599 aw.WearableData[i] = awb;
600 } 600 }
601 601
602 this.OutPacket(aw); 602 this.OutPacket(aw);
603 } 603 }
604 604
605 /// <summary> 605 /// <summary>
606 /// 606 ///
607 /// </summary> 607 /// </summary>
608 /// <param name="agentID"></param> 608 /// <param name="agentID"></param>
609 /// <param name="visualParams"></param> 609 /// <param name="visualParams"></param>
610 /// <param name="textureEntry"></param> 610 /// <param name="textureEntry"></param>
611 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) 611 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
612 { 612 {
613 AvatarAppearancePacket avp = new AvatarAppearancePacket(); 613 AvatarAppearancePacket avp = new AvatarAppearancePacket();
614 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; 614 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
615 avp.ObjectData.TextureEntry = textureEntry; 615 avp.ObjectData.TextureEntry = textureEntry;
616 616
617 AvatarAppearancePacket.VisualParamBlock avblock = null; 617 AvatarAppearancePacket.VisualParamBlock avblock = null;
618 for (int i = 0; i < visualParams.Length; i++) 618 for (int i = 0; i < visualParams.Length; i++)
619 { 619 {
620 avblock = new AvatarAppearancePacket.VisualParamBlock(); 620 avblock = new AvatarAppearancePacket.VisualParamBlock();
621 avblock.ParamValue = visualParams[i]; 621 avblock.ParamValue = visualParams[i];
622 avp.VisualParam[i] = avblock; 622 avp.VisualParam[i] = avblock;
623 } 623 }
624 624
625 avp.Sender.IsTrial = false; 625 avp.Sender.IsTrial = false;
626 avp.Sender.ID = agentID; 626 avp.Sender.ID = agentID;
627 OutPacket(avp); 627 OutPacket(avp);
628 } 628 }
629 629
630 public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) 630 public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId)
631 { 631 {
632 AvatarAnimationPacket ani = new AvatarAnimationPacket(); 632 AvatarAnimationPacket ani = new AvatarAnimationPacket();
633 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; 633 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
634 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); 634 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
635 ani.AnimationSourceList[0].ObjectID = sourceAgentId; 635 ani.AnimationSourceList[0].ObjectID = sourceAgentId;
636 ani.Sender = new AvatarAnimationPacket.SenderBlock(); 636 ani.Sender = new AvatarAnimationPacket.SenderBlock();
637 ani.Sender.ID = sourceAgentId; 637 ani.Sender.ID = sourceAgentId;
638 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; 638 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
639 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); 639 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
640 ani.AnimationList[0].AnimID = animID; 640 ani.AnimationList[0].AnimID = animID;
641 ani.AnimationList[0].AnimSequenceID = seq; 641 ani.AnimationList[0].AnimSequenceID = seq;
642 this.OutPacket(ani); 642 this.OutPacket(ani);
643 } 643 }
644 644
645 #endregion 645 #endregion
646 646
647 #region Avatar Packet/data sending Methods 647 #region Avatar Packet/data sending Methods
648 648
649 /// <summary> 649 /// <summary>
650 /// send a objectupdate packet with information about the clients avatar 650 /// send a objectupdate packet with information about the clients avatar
651 /// </summary> 651 /// </summary>
652 /// <param name="regionInfo"></param> 652 /// <param name="regionInfo"></param>
653 /// <param name="firstName"></param> 653 /// <param name="firstName"></param>
654 /// <param name="lastName"></param> 654 /// <param name="lastName"></param>
655 /// <param name="avatarID"></param> 655 /// <param name="avatarID"></param>
656 /// <param name="avatarLocalID"></param> 656 /// <param name="avatarLocalID"></param>
657 /// <param name="Pos"></param> 657 /// <param name="Pos"></param>
658 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) 658 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry)
659 { 659 {
660 ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); 660 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
661 objupdate.RegionData.RegionHandle = regionHandle; 661 objupdate.RegionData.RegionHandle = regionHandle;
662 objupdate.RegionData.TimeDilation = 64096; 662 objupdate.RegionData.TimeDilation = 64096;
663 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 663 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
664 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); 664 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry);
665 665
666 //give this avatar object a local id and assign the user a name 666 //give this avatar object a local id and assign the user a name
667 objupdate.ObjectData[0].ID = avatarLocalID; 667 objupdate.ObjectData[0].ID = avatarLocalID;
668 objupdate.ObjectData[0].FullID = avatarID; 668 objupdate.ObjectData[0].FullID = avatarID;
669 objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName ); 669 objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName );
670 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); 670 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
671 byte[] pb = pos2.GetBytes(); 671 byte[] pb = pos2.GetBytes();
672 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); 672 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
673 673
674 OutPacket(objupdate); 674 OutPacket(objupdate);
675 675
676 } 676 }
677 677
678 /// <summary> 678 /// <summary>
679 /// 679 ///
680 /// </summary> 680 /// </summary>
681 /// <param name="regionHandle"></param> 681 /// <param name="regionHandle"></param>
682 /// <param name="timeDilation"></param> 682 /// <param name="timeDilation"></param>
683 /// <param name="localID"></param> 683 /// <param name="localID"></param>
684 /// <param name="position"></param> 684 /// <param name="position"></param>
685 /// <param name="velocity"></param> 685 /// <param name="velocity"></param>
686 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) 686 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
687 { 687 {
688 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity); 688 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
689 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 689 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
690 terse.RegionData.RegionHandle = regionHandle; 690 terse.RegionData.RegionHandle = regionHandle;
691 terse.RegionData.TimeDilation = timeDilation; 691 terse.RegionData.TimeDilation = timeDilation;
692 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 692 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
693 terse.ObjectData[0] = terseBlock; 693 terse.ObjectData[0] = terseBlock;
694 694
695 this.OutPacket(terse); 695 this.OutPacket(terse);
696 } 696 }
697 697
698 #endregion 698 #endregion
699 699
700 #region Primitive Packet/data Sending Methods 700 #region Primitive Packet/data Sending Methods
701 701
702 /// <summary> 702 /// <summary>
703 /// 703 ///
704 /// </summary> 704 /// </summary>
705 /// <param name="localID"></param> 705 /// <param name="localID"></param>
706 /// <param name="rotation"></param> 706 /// <param name="rotation"></param>
707 /// <param name="attachPoint"></param> 707 /// <param name="attachPoint"></param>
708 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) 708 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
709 { 709 {
710 ObjectAttachPacket attach = new ObjectAttachPacket(); 710 ObjectAttachPacket attach = new ObjectAttachPacket();
711 attach.AgentData.AgentID = this.AgentID; 711 attach.AgentData.AgentID = this.AgentID;
712 attach.AgentData.SessionID = this.SessionID; 712 attach.AgentData.SessionID = this.SessionID;
713 attach.AgentData.AttachmentPoint = attachPoint; 713 attach.AgentData.AttachmentPoint = attachPoint;
714 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; 714 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
715 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); 715 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
716 attach.ObjectData[0].ObjectLocalID = localID; 716 attach.ObjectData[0].ObjectLocalID = localID;
717 attach.ObjectData[0].Rotation = rotation; 717 attach.ObjectData[0].Rotation = rotation;
718 718
719 this.OutPacket(attach); 719 this.OutPacket(attach);
720 } 720 }
721 721
722 /// <summary> 722 /// <summary>
723 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive 723 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
724 /// or big changes to a existing primitive. 724 /// or big changes to a existing primitive.
725 /// </summary> 725 /// </summary>
726 /// <param name="regionHandle"></param> 726 /// <param name="regionHandle"></param>
727 /// <param name="timeDilation"></param> 727 /// <param name="timeDilation"></param>
728 /// <param name="localID"></param> 728 /// <param name="localID"></param>
729 /// <param name="primData"></param> 729 /// <param name="primData"></param>
730 /// <param name="pos"></param> 730 /// <param name="pos"></param>
731 /// <param name="rotation"></param> 731 /// <param name="rotation"></param>
732 /// <param name="textureID"></param> 732 /// <param name="textureID"></param>
733 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) 733 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags)
734 { 734 {
735 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 735 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
736 outPacket.RegionData.RegionHandle = regionHandle; 736 outPacket.RegionData.RegionHandle = regionHandle;
737 outPacket.RegionData.TimeDilation = timeDilation; 737 outPacket.RegionData.TimeDilation = timeDilation;
738 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 738 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
739 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); 739 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
740 outPacket.ObjectData[0].ID = localID; 740 outPacket.ObjectData[0].ID = localID;
741 outPacket.ObjectData[0].FullID = primData.FullID; 741 outPacket.ObjectData[0].FullID = primData.FullID;
742 byte[] pb = pos.GetBytes(); 742 byte[] pb = pos.GetBytes();
743 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 743 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
744 byte[] rot = rotation.GetBytes(); 744 byte[] rot = rotation.GetBytes();
745 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length); 745 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
746 OutPacket(outPacket); 746 OutPacket(outPacket);
747 } 747 }
748 748
749 /// <summary> 749 /// <summary>
750 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive 750 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
751 /// or big changes to a existing primitive. 751 /// or big changes to a existing primitive.
752 /// Uses default rotation 752 /// Uses default rotation
753 /// </summary> 753 /// </summary>
754 /// <param name="primData"></param> 754 /// <param name="primData"></param>
755 /// <param name="pos"></param> 755 /// <param name="pos"></param>
756 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) 756 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags)
757 { 757 {
758 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 758 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
759 outPacket.RegionData.RegionHandle = regionHandle; 759 outPacket.RegionData.RegionHandle = regionHandle;
760 outPacket.RegionData.TimeDilation = timeDilation; 760 outPacket.RegionData.TimeDilation = timeDilation;
761 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 761 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
762 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); 762 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
763 outPacket.ObjectData[0].ID = localID; 763 outPacket.ObjectData[0].ID = localID;
764 outPacket.ObjectData[0].FullID = primData.FullID; 764 outPacket.ObjectData[0].FullID = primData.FullID;
765 byte[] pb = pos.GetBytes(); 765 byte[] pb = pos.GetBytes();
766 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 766 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
767 767
768 OutPacket(outPacket); 768 OutPacket(outPacket);
769 } 769 }
770 770
771 771
772 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) 772 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
773 { 773 {
774 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 774 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
775 outPacket.RegionData.RegionHandle = regionHandle; 775 outPacket.RegionData.RegionHandle = regionHandle;
776 outPacket.RegionData.TimeDilation = timeDilation; 776 outPacket.RegionData.TimeDilation = timeDilation;
777 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 777 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
778 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); 778 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags);
779 outPacket.ObjectData[0].ID = localID; 779 outPacket.ObjectData[0].ID = localID;
780 outPacket.ObjectData[0].FullID = objectID; 780 outPacket.ObjectData[0].FullID = objectID;
781 outPacket.ObjectData[0].OwnerID = ownerID; 781 outPacket.ObjectData[0].OwnerID = ownerID;
782 outPacket.ObjectData[0].Text = enc.GetBytes(text); 782 outPacket.ObjectData[0].Text = enc.GetBytes(text);
783 outPacket.ObjectData[0].ParentID = parentID; 783 outPacket.ObjectData[0].ParentID = parentID;
784 byte[] pb = pos.GetBytes(); 784 byte[] pb = pos.GetBytes();
785 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 785 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
786 byte[] rot = rotation.GetBytes(); 786 byte[] rot = rotation.GetBytes();
787 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); 787 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length);
788 OutPacket(outPacket); 788 OutPacket(outPacket);
789 } 789 }
790 790
791 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) 791 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
792 { 792 {
793 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 793 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
794 outPacket.RegionData.RegionHandle = regionHandle; 794 outPacket.RegionData.RegionHandle = regionHandle;
795 outPacket.RegionData.TimeDilation = timeDilation; 795 outPacket.RegionData.TimeDilation = timeDilation;
796 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 796 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
797 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); 797 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags);
798 outPacket.ObjectData[0].ID = localID; 798 outPacket.ObjectData[0].ID = localID;
799 outPacket.ObjectData[0].FullID = objectID; 799 outPacket.ObjectData[0].FullID = objectID;
800 outPacket.ObjectData[0].OwnerID = ownerID; 800 outPacket.ObjectData[0].OwnerID = ownerID;
801 outPacket.ObjectData[0].Text = enc.GetBytes(text); 801 outPacket.ObjectData[0].Text = enc.GetBytes(text);
802 outPacket.ObjectData[0].ParentID = parentID; 802 outPacket.ObjectData[0].ParentID = parentID;
803 byte[] pb = pos.GetBytes(); 803 byte[] pb = pos.GetBytes();
804 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 804 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
805 805
806 OutPacket(outPacket); 806 OutPacket(outPacket);
807 } 807 }
808 /// <summary> 808 /// <summary>
809 /// 809 ///
810 /// </summary> 810 /// </summary>
811 /// <param name="regionHandle"></param> 811 /// <param name="regionHandle"></param>
812 /// <param name="timeDilation"></param> 812 /// <param name="timeDilation"></param>
813 /// <param name="localID"></param> 813 /// <param name="localID"></param>
814 /// <param name="position"></param> 814 /// <param name="position"></param>
815 /// <param name="rotation"></param> 815 /// <param name="rotation"></param>
816 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) 816 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation)
817 { 817 {
818 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 818 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
819 terse.RegionData.RegionHandle = regionHandle; 819 terse.RegionData.RegionHandle = regionHandle;
820 terse.RegionData.TimeDilation = timeDilation; 820 terse.RegionData.TimeDilation = timeDilation;
821 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 821 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
822 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); 822 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation);
823 823
824 this.OutPacket(terse); 824 this.OutPacket(terse);
825 } 825 }
826 826
827 #endregion 827 #endregion
828 828
829 #endregion 829 #endregion
830 830
831 #region Helper Methods 831 #region Helper Methods
832 832
833 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity) 833 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
834 { 834 {
835 byte[] bytes = new byte[60]; 835 byte[] bytes = new byte[60];
836 int i = 0; 836 int i = 0;
837 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 837 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
838 838
839 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; 839 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
840 840
841 uint ID = localID; 841 uint ID = localID;
842 842
843 bytes[i++] = (byte)(ID % 256); 843 bytes[i++] = (byte)(ID % 256);
844 bytes[i++] = (byte)((ID >> 8) % 256); 844 bytes[i++] = (byte)((ID >> 8) % 256);
845 bytes[i++] = (byte)((ID >> 16) % 256); 845 bytes[i++] = (byte)((ID >> 16) % 256);
846 bytes[i++] = (byte)((ID >> 24) % 256); 846 bytes[i++] = (byte)((ID >> 24) % 256);
847 bytes[i++] = 0; 847 bytes[i++] = 0;
848 bytes[i++] = 1; 848 bytes[i++] = 1;
849 i += 14; 849 i += 14;
850 bytes[i++] = 128; 850 bytes[i++] = 128;
851 bytes[i++] = 63; 851 bytes[i++] = 63;
852 852
853 byte[] pb = pos.GetBytes(); 853 byte[] pb = pos.GetBytes();
854 Array.Copy(pb, 0, bytes, i, pb.Length); 854 Array.Copy(pb, 0, bytes, i, pb.Length);
855 i += 12; 855 i += 12;
856 ushort InternVelocityX; 856 ushort InternVelocityX;
857 ushort InternVelocityY; 857 ushort InternVelocityY;
858 ushort InternVelocityZ; 858 ushort InternVelocityZ;
859 Vector3 internDirec = new Vector3(0, 0, 0); 859 Vector3 internDirec = new Vector3(0, 0, 0);
860 860
861 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); 861 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z);
862 862
863 internDirec = internDirec / 128.0f; 863 internDirec = internDirec / 128.0f;
864 internDirec.x += 1; 864 internDirec.x += 1;
865 internDirec.y += 1; 865 internDirec.y += 1;
866 internDirec.z += 1; 866 internDirec.z += 1;
867 867
868 InternVelocityX = (ushort)(32768 * internDirec.x); 868 InternVelocityX = (ushort)(32768 * internDirec.x);
869 InternVelocityY = (ushort)(32768 * internDirec.y); 869 InternVelocityY = (ushort)(32768 * internDirec.y);
870 InternVelocityZ = (ushort)(32768 * internDirec.z); 870 InternVelocityZ = (ushort)(32768 * internDirec.z);
871 871
872 ushort ac = 32767; 872 ushort ac = 32767;
873 bytes[i++] = (byte)(InternVelocityX % 256); 873 bytes[i++] = (byte)(InternVelocityX % 256);
874 bytes[i++] = (byte)((InternVelocityX >> 8) % 256); 874 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
875 bytes[i++] = (byte)(InternVelocityY % 256); 875 bytes[i++] = (byte)(InternVelocityY % 256);
876 bytes[i++] = (byte)((InternVelocityY >> 8) % 256); 876 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
877 bytes[i++] = (byte)(InternVelocityZ % 256); 877 bytes[i++] = (byte)(InternVelocityZ % 256);
878 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); 878 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
879 879
880 //accel 880 //accel
881 bytes[i++] = (byte)(ac % 256); 881 bytes[i++] = (byte)(ac % 256);
882 bytes[i++] = (byte)((ac >> 8) % 256); 882 bytes[i++] = (byte)((ac >> 8) % 256);
883 bytes[i++] = (byte)(ac % 256); 883 bytes[i++] = (byte)(ac % 256);
884 bytes[i++] = (byte)((ac >> 8) % 256); 884 bytes[i++] = (byte)((ac >> 8) % 256);
885 bytes[i++] = (byte)(ac % 256); 885 bytes[i++] = (byte)(ac % 256);
886 bytes[i++] = (byte)((ac >> 8) % 256); 886 bytes[i++] = (byte)((ac >> 8) % 256);
887 887
888 //rot 888 //rot
889 bytes[i++] = (byte)(ac % 256); 889 bytes[i++] = (byte)(ac % 256);
890 bytes[i++] = (byte)((ac >> 8) % 256); 890 bytes[i++] = (byte)((ac >> 8) % 256);
891 bytes[i++] = (byte)(ac % 256); 891 bytes[i++] = (byte)(ac % 256);
892 bytes[i++] = (byte)((ac >> 8) % 256); 892 bytes[i++] = (byte)((ac >> 8) % 256);
893 bytes[i++] = (byte)(ac % 256); 893 bytes[i++] = (byte)(ac % 256);
894 bytes[i++] = (byte)((ac >> 8) % 256); 894 bytes[i++] = (byte)((ac >> 8) % 256);
895 bytes[i++] = (byte)(ac % 256); 895 bytes[i++] = (byte)(ac % 256);
896 bytes[i++] = (byte)((ac >> 8) % 256); 896 bytes[i++] = (byte)((ac >> 8) % 256);
897 897
898 //rotation vel 898 //rotation vel
899 bytes[i++] = (byte)(ac % 256); 899 bytes[i++] = (byte)(ac % 256);
900 bytes[i++] = (byte)((ac >> 8) % 256); 900 bytes[i++] = (byte)((ac >> 8) % 256);
901 bytes[i++] = (byte)(ac % 256); 901 bytes[i++] = (byte)(ac % 256);
902 bytes[i++] = (byte)((ac >> 8) % 256); 902 bytes[i++] = (byte)((ac >> 8) % 256);
903 bytes[i++] = (byte)(ac % 256); 903 bytes[i++] = (byte)(ac % 256);
904 bytes[i++] = (byte)((ac >> 8) % 256); 904 bytes[i++] = (byte)((ac >> 8) % 256);
905 905
906 dat.Data = bytes; 906 dat.Data = bytes;
907 return (dat); 907 return (dat);
908 } 908 }
909 909
910 /// <summary> 910 /// <summary>
911 /// 911 ///
912 /// </summary> 912 /// </summary>
913 /// <param name="localID"></param> 913 /// <param name="localID"></param>
914 /// <param name="position"></param> 914 /// <param name="position"></param>
915 /// <param name="rotation"></param> 915 /// <param name="rotation"></param>
916 /// <returns></returns> 916 /// <returns></returns>
917 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) 917 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation)
918 { 918 {
919 uint ID = localID; 919 uint ID = localID;
920 byte[] bytes = new byte[60]; 920 byte[] bytes = new byte[60];
921 921
922 int i = 0; 922 int i = 0;
923 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 923 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
924 dat.TextureEntry = new byte[0]; 924 dat.TextureEntry = new byte[0];
925 bytes[i++] = (byte)(ID % 256); 925 bytes[i++] = (byte)(ID % 256);
926 bytes[i++] = (byte)((ID >> 8) % 256); 926 bytes[i++] = (byte)((ID >> 8) % 256);
927 bytes[i++] = (byte)((ID >> 16) % 256); 927 bytes[i++] = (byte)((ID >> 16) % 256);
928 bytes[i++] = (byte)((ID >> 24) % 256); 928 bytes[i++] = (byte)((ID >> 24) % 256);
929 bytes[i++] = 0; 929 bytes[i++] = 0;
930 bytes[i++] = 0; 930 bytes[i++] = 0;
931 931
932 byte[] pb = position.GetBytes(); 932 byte[] pb = position.GetBytes();
933 Array.Copy(pb, 0, bytes, i, pb.Length); 933 Array.Copy(pb, 0, bytes, i, pb.Length);
934 i += 12; 934 i += 12;
935 ushort ac = 32767; 935 ushort ac = 32767;
936 936
937 //vel 937 //vel
938 bytes[i++] = (byte)(ac % 256); 938 bytes[i++] = (byte)(ac % 256);
939 bytes[i++] = (byte)((ac >> 8) % 256); 939 bytes[i++] = (byte)((ac >> 8) % 256);
940 bytes[i++] = (byte)(ac % 256); 940 bytes[i++] = (byte)(ac % 256);
941 bytes[i++] = (byte)((ac >> 8) % 256); 941 bytes[i++] = (byte)((ac >> 8) % 256);
942 bytes[i++] = (byte)(ac % 256); 942 bytes[i++] = (byte)(ac % 256);
943 bytes[i++] = (byte)((ac >> 8) % 256); 943 bytes[i++] = (byte)((ac >> 8) % 256);
944 944
945 //accel 945 //accel
946 bytes[i++] = (byte)(ac % 256); 946 bytes[i++] = (byte)(ac % 256);
947 bytes[i++] = (byte)((ac >> 8) % 256); 947 bytes[i++] = (byte)((ac >> 8) % 256);
948 bytes[i++] = (byte)(ac % 256); 948 bytes[i++] = (byte)(ac % 256);
949 bytes[i++] = (byte)((ac >> 8) % 256); 949 bytes[i++] = (byte)((ac >> 8) % 256);
950 bytes[i++] = (byte)(ac % 256); 950 bytes[i++] = (byte)(ac % 256);
951 bytes[i++] = (byte)((ac >> 8) % 256); 951 bytes[i++] = (byte)((ac >> 8) % 256);
952 952
953 ushort rw, rx, ry, rz; 953 ushort rw, rx, ry, rz;
954 rw = (ushort)(32768 * (rotation.W + 1)); 954 rw = (ushort)(32768 * (rotation.W + 1));
955 rx = (ushort)(32768 * (rotation.X + 1)); 955 rx = (ushort)(32768 * (rotation.X + 1));
956 ry = (ushort)(32768 * (rotation.Y + 1)); 956 ry = (ushort)(32768 * (rotation.Y + 1));
957 rz = (ushort)(32768 * (rotation.Z + 1)); 957 rz = (ushort)(32768 * (rotation.Z + 1));
958 958
959 //rot 959 //rot
960 bytes[i++] = (byte)(rx % 256); 960 bytes[i++] = (byte)(rx % 256);
961 bytes[i++] = (byte)((rx >> 8) % 256); 961 bytes[i++] = (byte)((rx >> 8) % 256);
962 bytes[i++] = (byte)(ry % 256); 962 bytes[i++] = (byte)(ry % 256);
963 bytes[i++] = (byte)((ry >> 8) % 256); 963 bytes[i++] = (byte)((ry >> 8) % 256);
964 bytes[i++] = (byte)(rz % 256); 964 bytes[i++] = (byte)(rz % 256);
965 bytes[i++] = (byte)((rz >> 8) % 256); 965 bytes[i++] = (byte)((rz >> 8) % 256);
966 bytes[i++] = (byte)(rw % 256); 966 bytes[i++] = (byte)(rw % 256);
967 bytes[i++] = (byte)((rw >> 8) % 256); 967 bytes[i++] = (byte)((rw >> 8) % 256);
968 968
969 //rotation vel 969 //rotation vel
970 bytes[i++] = (byte)(ac % 256); 970 bytes[i++] = (byte)(ac % 256);
971 bytes[i++] = (byte)((ac >> 8) % 256); 971 bytes[i++] = (byte)((ac >> 8) % 256);
972 bytes[i++] = (byte)(ac % 256); 972 bytes[i++] = (byte)(ac % 256);
973 bytes[i++] = (byte)((ac >> 8) % 256); 973 bytes[i++] = (byte)((ac >> 8) % 256);
974 bytes[i++] = (byte)(ac % 256); 974 bytes[i++] = (byte)(ac % 256);
975 bytes[i++] = (byte)((ac >> 8) % 256); 975 bytes[i++] = (byte)((ac >> 8) % 256);
976 976
977 dat.Data = bytes; 977 dat.Data = bytes;
978 return dat; 978 return dat;
979 } 979 }
980 980
981 981
982 /// <summary> 982 /// <summary>
983 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) 983 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
984 /// </summary> 984 /// </summary>
985 /// <param name="primData"></param> 985 /// <param name="primData"></param>
986 /// <returns></returns> 986 /// <returns></returns>
987 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags) 987 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags)
988 { 988 {
989 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 989 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
990 this.SetDefaultPrimPacketValues(objupdate); 990 this.SetDefaultPrimPacketValues(objupdate);
991 objupdate.UpdateFlags = flags; 991 objupdate.UpdateFlags = flags;
992 this.SetPrimPacketShapeData(objupdate, primData, textureID); 992 this.SetPrimPacketShapeData(objupdate, primData, textureID);
993 993
994 return objupdate; 994 return objupdate;
995 } 995 }
996 996
997 /// <summary> 997 /// <summary>
998 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) 998 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
999 /// </summary> 999 /// </summary>
1000 /// <param name="primData"></param> 1000 /// <param name="primData"></param>
1001 /// <returns></returns> 1001 /// <returns></returns>
1002 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) 1002 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags)
1003 { 1003 {
1004 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 1004 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
1005 this.SetDefaultPrimPacketValues(objupdate); 1005 this.SetDefaultPrimPacketValues(objupdate);
1006 objupdate.UpdateFlags = flags; 1006 objupdate.UpdateFlags = flags;
1007 this.SetPrimPacketShapeData(objupdate, primShape); 1007 this.SetPrimPacketShapeData(objupdate, primShape);
1008 1008
1009 return objupdate; 1009 return objupdate;
1010 } 1010 }
1011 1011
1012 1012
1013 /// <summary> 1013 /// <summary>
1014 /// Copy the data from a PrimData object to a ObjectUpdatePacket 1014 /// Copy the data from a PrimData object to a ObjectUpdatePacket
1015 /// </summary> 1015 /// </summary>
1016 /// <param name="objectData"></param> 1016 /// <param name="objectData"></param>
1017 /// <param name="primData"></param> 1017 /// <param name="primData"></param>
1018 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID) 1018 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID)
1019 { 1019 {
1020 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); 1020 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
1021 objectData.TextureEntry = ntex.ToBytes(); 1021 objectData.TextureEntry = ntex.ToBytes();
1022 objectData.OwnerID = primData.OwnerID; 1022 objectData.OwnerID = primData.OwnerID;
1023 objectData.ParentID = primData.ParentID; 1023 objectData.ParentID = primData.ParentID;
1024 objectData.PCode = primData.PCode; 1024 objectData.PCode = primData.PCode;
1025 objectData.PathBegin = primData.PathBegin; 1025 objectData.PathBegin = primData.PathBegin;
1026 objectData.PathEnd = primData.PathEnd; 1026 objectData.PathEnd = primData.PathEnd;
1027 objectData.PathScaleX = primData.PathScaleX; 1027 objectData.PathScaleX = primData.PathScaleX;
1028 objectData.PathScaleY = primData.PathScaleY; 1028 objectData.PathScaleY = primData.PathScaleY;
1029 objectData.PathShearX = primData.PathShearX; 1029 objectData.PathShearX = primData.PathShearX;
1030 objectData.PathShearY = primData.PathShearY; 1030 objectData.PathShearY = primData.PathShearY;
1031 objectData.PathSkew = primData.PathSkew; 1031 objectData.PathSkew = primData.PathSkew;
1032 objectData.ProfileBegin = primData.ProfileBegin; 1032 objectData.ProfileBegin = primData.ProfileBegin;
1033 objectData.ProfileEnd = primData.ProfileEnd; 1033 objectData.ProfileEnd = primData.ProfileEnd;
1034 objectData.Scale = primData.Scale; 1034 objectData.Scale = primData.Scale;
1035 objectData.PathCurve = primData.PathCurve; 1035 objectData.PathCurve = primData.PathCurve;
1036 objectData.ProfileCurve = primData.ProfileCurve; 1036 objectData.ProfileCurve = primData.ProfileCurve;
1037 objectData.ProfileHollow = primData.ProfileHollow; 1037 objectData.ProfileHollow = primData.ProfileHollow;
1038 objectData.PathRadiusOffset = primData.PathRadiusOffset; 1038 objectData.PathRadiusOffset = primData.PathRadiusOffset;
1039 objectData.PathRevolutions = primData.PathRevolutions; 1039 objectData.PathRevolutions = primData.PathRevolutions;
1040 objectData.PathTaperX = primData.PathTaperX; 1040 objectData.PathTaperX = primData.PathTaperX;
1041 objectData.PathTaperY = primData.PathTaperY; 1041 objectData.PathTaperY = primData.PathTaperY;
1042 objectData.PathTwist = primData.PathTwist; 1042 objectData.PathTwist = primData.PathTwist;
1043 objectData.PathTwistBegin = primData.PathTwistBegin; 1043 objectData.PathTwistBegin = primData.PathTwistBegin;
1044 } 1044 }
1045 1045
1046 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) 1046 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData)
1047 { 1047 {
1048 1048
1049 objectData.TextureEntry = primData.TextureEntry; 1049 objectData.TextureEntry = primData.TextureEntry;
1050 objectData.PCode = primData.PCode; 1050 objectData.PCode = primData.PCode;
1051 objectData.PathBegin = primData.PathBegin; 1051 objectData.PathBegin = primData.PathBegin;
1052 objectData.PathEnd = primData.PathEnd; 1052 objectData.PathEnd = primData.PathEnd;
1053 objectData.PathScaleX = primData.PathScaleX; 1053 objectData.PathScaleX = primData.PathScaleX;
1054 objectData.PathScaleY = primData.PathScaleY; 1054 objectData.PathScaleY = primData.PathScaleY;
1055 objectData.PathShearX = primData.PathShearX; 1055 objectData.PathShearX = primData.PathShearX;
1056 objectData.PathShearY = primData.PathShearY; 1056 objectData.PathShearY = primData.PathShearY;
1057 objectData.PathSkew = primData.PathSkew; 1057 objectData.PathSkew = primData.PathSkew;
1058 objectData.ProfileBegin = primData.ProfileBegin; 1058 objectData.ProfileBegin = primData.ProfileBegin;
1059 objectData.ProfileEnd = primData.ProfileEnd; 1059 objectData.ProfileEnd = primData.ProfileEnd;
1060 objectData.Scale = primData.Scale; 1060 objectData.Scale = primData.Scale;
1061 objectData.PathCurve = primData.PathCurve; 1061 objectData.PathCurve = primData.PathCurve;
1062 objectData.ProfileCurve = primData.ProfileCurve; 1062 objectData.ProfileCurve = primData.ProfileCurve;
1063 objectData.ProfileHollow = primData.ProfileHollow; 1063 objectData.ProfileHollow = primData.ProfileHollow;
1064 objectData.PathRadiusOffset = primData.PathRadiusOffset; 1064 objectData.PathRadiusOffset = primData.PathRadiusOffset;
1065 objectData.PathRevolutions = primData.PathRevolutions; 1065 objectData.PathRevolutions = primData.PathRevolutions;
1066 objectData.PathTaperX = primData.PathTaperX; 1066 objectData.PathTaperX = primData.PathTaperX;
1067 objectData.PathTaperY = primData.PathTaperY; 1067 objectData.PathTaperY = primData.PathTaperY;
1068 objectData.PathTwist = primData.PathTwist; 1068 objectData.PathTwist = primData.PathTwist;
1069 objectData.PathTwistBegin = primData.PathTwistBegin; 1069 objectData.PathTwistBegin = primData.PathTwistBegin;
1070 } 1070 }
1071 1071
1072 /// <summary> 1072 /// <summary>
1073 /// Set some default values in a ObjectUpdatePacket 1073 /// Set some default values in a ObjectUpdatePacket
1074 /// </summary> 1074 /// </summary>
1075 /// <param name="objdata"></param> 1075 /// <param name="objdata"></param>
1076 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) 1076 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
1077 { 1077 {
1078 objdata.PSBlock = new byte[0]; 1078 objdata.PSBlock = new byte[0];
1079 objdata.ExtraParams = new byte[1]; 1079 objdata.ExtraParams = new byte[1];
1080 objdata.MediaURL = new byte[0]; 1080 objdata.MediaURL = new byte[0];
1081 objdata.NameValue = new byte[0]; 1081 objdata.NameValue = new byte[0];
1082 objdata.Text = new byte[0]; 1082 objdata.Text = new byte[0];
1083 objdata.TextColor = new byte[4]; 1083 objdata.TextColor = new byte[4];
1084 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 1084 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1085 objdata.JointPivot = new LLVector3(0, 0, 0); 1085 objdata.JointPivot = new LLVector3(0, 0, 0);
1086 objdata.Material = 3; 1086 objdata.Material = 3;
1087 objdata.TextureAnim = new byte[0]; 1087 objdata.TextureAnim = new byte[0];
1088 objdata.Sound = LLUUID.Zero; 1088 objdata.Sound = LLUUID.Zero;
1089 objdata.State = 0; 1089 objdata.State = 0;
1090 objdata.Data = new byte[0]; 1090 objdata.Data = new byte[0];
1091 1091
1092 objdata.ObjectData = new byte[60]; 1092 objdata.ObjectData = new byte[60];
1093 objdata.ObjectData[46] = 128; 1093 objdata.ObjectData[46] = 128;
1094 objdata.ObjectData[47] = 63; 1094 objdata.ObjectData[47] = 63;
1095 } 1095 }
1096 1096
1097 1097
1098 /// <summary> 1098 /// <summary>
1099 /// 1099 ///
1100 /// </summary> 1100 /// </summary>
1101 /// <returns></returns> 1101 /// <returns></returns>
1102 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) 1102 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
1103 { 1103 {
1104 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); 1104 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
1105 1105
1106 SetDefaultAvatarPacketValues(ref objdata); 1106 SetDefaultAvatarPacketValues(ref objdata);
1107 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); 1107 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
1108 objdata.PathCurve = 16; 1108 objdata.PathCurve = 16;
1109 objdata.ProfileCurve = 1; 1109 objdata.ProfileCurve = 1;
1110 objdata.PathScaleX = 100; 1110 objdata.PathScaleX = 100;
1111 objdata.PathScaleY = 100; 1111 objdata.PathScaleY = 100;
1112 objdata.ParentID = 0; 1112 objdata.ParentID = 0;
1113 objdata.OwnerID = LLUUID.Zero; 1113 objdata.OwnerID = LLUUID.Zero;
1114 objdata.Scale = new LLVector3(1, 1, 1); 1114 objdata.Scale = new LLVector3(1, 1, 1);
1115 objdata.PCode = 47; 1115 objdata.PCode = 47;
1116 if (textureEntry != null) 1116 if (textureEntry != null)
1117 { 1117 {
1118 objdata.TextureEntry = textureEntry; 1118 objdata.TextureEntry = textureEntry;
1119 } 1119 }
1120 Encoding enc = Encoding.ASCII; 1120 Encoding enc = Encoding.ASCII;
1121 LLVector3 pos = new LLVector3(objdata.ObjectData, 16); 1121 LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
1122 pos.X = 100f; 1122 pos.X = 100f;
1123 objdata.ID = 8880000; 1123 objdata.ID = 8880000;
1124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); 1124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
1125 LLVector3 pos2 = new LLVector3(100f, 100f, 23f); 1125 LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
1126 //objdata.FullID=user.AgentID; 1126 //objdata.FullID=user.AgentID;
1127 byte[] pb = pos.GetBytes(); 1127 byte[] pb = pos.GetBytes();
1128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); 1128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
1129 1129
1130 return objdata; 1130 return objdata;
1131 } 1131 }
1132 1132
1133 /// <summary> 1133 /// <summary>
1134 /// 1134 ///
1135 /// </summary> 1135 /// </summary>
1136 /// <param name="objdata"></param> 1136 /// <param name="objdata"></param>
1137 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) 1137 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
1138 { 1138 {
1139 objdata.PSBlock = new byte[0]; 1139 objdata.PSBlock = new byte[0];
1140 objdata.ExtraParams = new byte[1]; 1140 objdata.ExtraParams = new byte[1];
1141 objdata.MediaURL = new byte[0]; 1141 objdata.MediaURL = new byte[0];
1142 objdata.NameValue = new byte[0]; 1142 objdata.NameValue = new byte[0];
1143 objdata.Text = new byte[0]; 1143 objdata.Text = new byte[0];
1144 objdata.TextColor = new byte[4]; 1144 objdata.TextColor = new byte[4];
1145 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 1145 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1146 objdata.JointPivot = new LLVector3(0, 0, 0); 1146 objdata.JointPivot = new LLVector3(0, 0, 0);
1147 objdata.Material = 4; 1147 objdata.Material = 4;
1148 objdata.TextureAnim = new byte[0]; 1148 objdata.TextureAnim = new byte[0];
1149 objdata.Sound = LLUUID.Zero; 1149 objdata.Sound = LLUUID.Zero;
1150 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 1150 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
1151 objdata.TextureEntry = ntex.ToBytes(); 1151 objdata.TextureEntry = ntex.ToBytes();
1152 objdata.State = 0; 1152 objdata.State = 0;
1153 objdata.Data = new byte[0]; 1153 objdata.Data = new byte[0];
1154 1154
1155 objdata.ObjectData = new byte[76]; 1155 objdata.ObjectData = new byte[76];
1156 objdata.ObjectData[15] = 128; 1156 objdata.ObjectData[15] = 128;
1157 objdata.ObjectData[16] = 63; 1157 objdata.ObjectData[16] = 63;
1158 objdata.ObjectData[56] = 128; 1158 objdata.ObjectData[56] = 128;
1159 objdata.ObjectData[61] = 102; 1159 objdata.ObjectData[61] = 102;
1160 objdata.ObjectData[62] = 40; 1160 objdata.ObjectData[62] = 40;
1161 objdata.ObjectData[63] = 61; 1161 objdata.ObjectData[63] = 61;
1162 objdata.ObjectData[64] = 189; 1162 objdata.ObjectData[64] = 189;
1163 } 1163 }
1164 1164
1165 #endregion 1165 #endregion
1166 1166
1167 public void SendNameReply(LLUUID profileId, string firstname, string lastname) 1167 public void SendNameReply(LLUUID profileId, string firstname, string lastname)
1168 { 1168 {
1169 UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); 1169 UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
1170 1170
1171 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; 1171 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
1172 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); 1172 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
1173 packet.UUIDNameBlock[0].ID = profileId; 1173 packet.UUIDNameBlock[0].ID = profileId;
1174 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname ); 1174 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname );
1175 packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname ); 1175 packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname );
1176 1176
1177 OutPacket( packet ); 1177 OutPacket( packet );
1178 } 1178 }
1179 } 1179 }
1180} 1180}
diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
index 60cd33a..109f7e6 100644
--- a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
+++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs
@@ -1,357 +1,357 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Assets; 32using OpenSim.Assets;
33using OpenSim.Framework.Interfaces; 33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities; 35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Caches; 36using OpenSim.Region.Caches;
37 37
38namespace OpenSim.Region.ClientStack 38namespace OpenSim.Region.ClientStack
39{ 39{
40 partial class ClientView 40 partial class ClientView
41 { 41 {
42 public class AgentAssetUpload 42 public class AgentAssetUpload
43 { 43 {
44 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); 44 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
45 private ClientView ourClient; 45 private ClientView ourClient;
46 private AssetCache m_assetCache; 46 private AssetCache m_assetCache;
47 private InventoryCache m_inventoryCache; 47 private InventoryCache m_inventoryCache;
48 48
49 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache) 49 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
50 { 50 {
51 this.ourClient = client; 51 this.ourClient = client;
52 m_assetCache = assetCache; 52 m_assetCache = assetCache;
53 m_inventoryCache = inventoryCache; 53 m_inventoryCache = inventoryCache;
54 } 54 }
55 55
56 public void AddUpload(LLUUID transactionID, AssetBase asset) 56 public void AddUpload(LLUUID transactionID, AssetBase asset)
57 { 57 {
58 AssetTransaction upload = new AssetTransaction(); 58 AssetTransaction upload = new AssetTransaction();
59 lock (this.transactions) 59 lock (this.transactions)
60 { 60 {
61 upload.Asset = asset; 61 upload.Asset = asset;
62 upload.TransactionID = transactionID; 62 upload.TransactionID = transactionID;
63 this.transactions.Add(transactionID, upload); 63 this.transactions.Add(transactionID, upload);
64 } 64 }
65 if (upload.Asset.Data.Length > 2) 65 if (upload.Asset.Data.Length > 2)
66 { 66 {
67 //is complete 67 //is complete
68 upload.UploadComplete = true; 68 upload.UploadComplete = true;
69 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 69 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
70 response.AssetBlock.Type = asset.Type; 70 response.AssetBlock.Type = asset.Type;
71 response.AssetBlock.Success = true; 71 response.AssetBlock.Success = true;
72 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID); 72 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
73 this.ourClient.OutPacket(response); 73 this.ourClient.OutPacket(response);
74 m_assetCache.AddAsset(asset); 74 m_assetCache.AddAsset(asset);
75 } 75 }
76 else 76 else
77 { 77 {
78 upload.UploadComplete = false; 78 upload.UploadComplete = false;
79 upload.XferID = Util.GetNextXferID(); 79 upload.XferID = Util.GetNextXferID();
80 RequestXferPacket xfer = new RequestXferPacket(); 80 RequestXferPacket xfer = new RequestXferPacket();
81 xfer.XferID.ID = upload.XferID; 81 xfer.XferID.ID = upload.XferID;
82 xfer.XferID.VFileType = upload.Asset.Type; 82 xfer.XferID.VFileType = upload.Asset.Type;
83 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID); 83 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
84 xfer.XferID.FilePath = 0; 84 xfer.XferID.FilePath = 0;
85 xfer.XferID.Filename = new byte[0]; 85 xfer.XferID.Filename = new byte[0];
86 this.ourClient.OutPacket(xfer); 86 this.ourClient.OutPacket(xfer);
87 } 87 }
88 88
89 } 89 }
90 90
91 public AssetBase GetUpload(LLUUID transactionID) 91 public AssetBase GetUpload(LLUUID transactionID)
92 { 92 {
93 if (this.transactions.ContainsKey(transactionID)) 93 if (this.transactions.ContainsKey(transactionID))
94 { 94 {
95 return this.transactions[transactionID].Asset; 95 return this.transactions[transactionID].Asset;
96 } 96 }
97 97
98 return null; 98 return null;
99 } 99 }
100 100
101 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID) 101 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID)
102 { 102 {
103 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString()); 103 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString());
104 AssetBase asset = null; 104 AssetBase asset = null;
105 if (pack.AssetBlock.Type == 0) 105 if (pack.AssetBlock.Type == 0)
106 { 106 {
107 107
108 //first packet for transaction 108 //first packet for transaction
109 asset = new AssetBase(); 109 asset = new AssetBase();
110 asset.FullID = assetID; 110 asset.FullID = assetID;
111 asset.Type = pack.AssetBlock.Type; 111 asset.Type = pack.AssetBlock.Type;
112 asset.InvType = asset.Type; 112 asset.InvType = asset.Type;
113 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); 113 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
114 asset.Data = pack.AssetBlock.AssetData; 114 asset.Data = pack.AssetBlock.AssetData;
115 115
116 116
117 } 117 }
118 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7) 118 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7)
119 { 119 {
120 120
121 asset = new AssetBase(); 121 asset = new AssetBase();
122 asset.FullID = assetID; 122 asset.FullID = assetID;
123 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated()); 123 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated());
124 asset.Type = pack.AssetBlock.Type; 124 asset.Type = pack.AssetBlock.Type;
125 asset.InvType = asset.Type; 125 asset.InvType = asset.Type;
126 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000"); 126 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000");
127 asset.Data = pack.AssetBlock.AssetData; 127 asset.Data = pack.AssetBlock.AssetData;
128 128
129 129
130 } 130 }
131 131
132 if (asset != null) 132 if (asset != null)
133 { 133 {
134 this.AddUpload(pack.AssetBlock.TransactionID, asset); 134 this.AddUpload(pack.AssetBlock.TransactionID, asset);
135 } 135 }
136 else 136 else
137 { 137 {
138 138
139 //currently we don't support this asset type 139 //currently we don't support this asset type
140 //so lets just tell the client that the upload is complete 140 //so lets just tell the client that the upload is complete
141 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 141 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
142 response.AssetBlock.Type = pack.AssetBlock.Type; 142 response.AssetBlock.Type = pack.AssetBlock.Type;
143 response.AssetBlock.Success = true; 143 response.AssetBlock.Success = true;
144 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID); 144 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID);
145 this.ourClient.OutPacket(response); 145 this.ourClient.OutPacket(response);
146 } 146 }
147 147
148 } 148 }
149 149
150 #region Xfer packet system for larger uploads 150 #region Xfer packet system for larger uploads
151 151
152 public void HandleXferPacket(SendXferPacketPacket xferPacket) 152 public void HandleXferPacket(SendXferPacketPacket xferPacket)
153 { 153 {
154 lock (this.transactions) 154 lock (this.transactions)
155 { 155 {
156 foreach (AssetTransaction trans in this.transactions.Values) 156 foreach (AssetTransaction trans in this.transactions.Values)
157 { 157 {
158 if (trans.XferID == xferPacket.XferID.ID) 158 if (trans.XferID == xferPacket.XferID.ID)
159 { 159 {
160 if (trans.Asset.Data.Length > 1) 160 if (trans.Asset.Data.Length > 1)
161 { 161 {
162 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length]; 162 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length];
163 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length); 163 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length);
164 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length); 164 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length);
165 trans.Asset.Data = newArray; 165 trans.Asset.Data = newArray;
166 } 166 }
167 else 167 else
168 { 168 {
169 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4]; 169 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4];
170 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4); 170 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4);
171 trans.Asset.Data = newArray; 171 trans.Asset.Data = newArray;
172 } 172 }
173 173
174 if ((xferPacket.XferID.Packet & 2147483648) != 0) 174 if ((xferPacket.XferID.Packet & 2147483648) != 0)
175 { 175 {
176 //end of transfer 176 //end of transfer
177 trans.UploadComplete = true; 177 trans.UploadComplete = true;
178 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 178 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
179 response.AssetBlock.Type = trans.Asset.Type; 179 response.AssetBlock.Type = trans.Asset.Type;
180 response.AssetBlock.Success = true; 180 response.AssetBlock.Success = true;
181 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID); 181 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID);
182 this.ourClient.OutPacket(response); 182 this.ourClient.OutPacket(response);
183 183
184 m_assetCache.AddAsset(trans.Asset); 184 m_assetCache.AddAsset(trans.Asset);
185 //check if we should add it to inventory 185 //check if we should add it to inventory
186 if (trans.AddToInventory) 186 if (trans.AddToInventory)
187 { 187 {
188 // m_assetCache.AddAsset(trans.Asset); 188 // m_assetCache.AddAsset(trans.Asset);
189 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset); 189 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset);
190 } 190 }
191 191
192 192
193 } 193 }
194 break; 194 break;
195 } 195 }
196 196
197 } 197 }
198 } 198 }
199 199
200 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); 200 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
201 confirmXfer.XferID.ID = xferPacket.XferID.ID; 201 confirmXfer.XferID.ID = xferPacket.XferID.ID;
202 confirmXfer.XferID.Packet = xferPacket.XferID.Packet; 202 confirmXfer.XferID.Packet = xferPacket.XferID.Packet;
203 this.ourClient.OutPacket(confirmXfer); 203 this.ourClient.OutPacket(confirmXfer);
204 } 204 }
205 205
206 #endregion 206 #endregion
207 207
208 public AssetBase AddUploadToAssetCache(LLUUID transactionID) 208 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
209 { 209 {
210 AssetBase asset = null; 210 AssetBase asset = null;
211 if (this.transactions.ContainsKey(transactionID)) 211 if (this.transactions.ContainsKey(transactionID))
212 { 212 {
213 AssetTransaction trans = this.transactions[transactionID]; 213 AssetTransaction trans = this.transactions[transactionID];
214 if (trans.UploadComplete) 214 if (trans.UploadComplete)
215 { 215 {
216 m_assetCache.AddAsset(trans.Asset); 216 m_assetCache.AddAsset(trans.Asset);
217 asset = trans.Asset; 217 asset = trans.Asset;
218 } 218 }
219 } 219 }
220 220
221 return asset; 221 return asset;
222 } 222 }
223 223
224 public void CreateInventoryItem(CreateInventoryItemPacket packet) 224 public void CreateInventoryItem(CreateInventoryItemPacket packet)
225 { 225 {
226 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) 226 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID))
227 { 227 {
228 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID]; 228 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID];
229 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description); 229 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
230 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name); 230 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
231 trans.Asset.Type = packet.InventoryBlock.Type; 231 trans.Asset.Type = packet.InventoryBlock.Type;
232 trans.Asset.InvType = packet.InventoryBlock.InvType; 232 trans.Asset.InvType = packet.InventoryBlock.InvType;
233 if (trans.UploadComplete) 233 if (trans.UploadComplete)
234 { 234 {
235 //already complete so we can add it to the inventory 235 //already complete so we can add it to the inventory
236 //m_assetCache.AddAsset(trans.Asset); 236 //m_assetCache.AddAsset(trans.Asset);
237 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset); 237 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset);
238 } 238 }
239 else 239 else
240 { 240 {
241 trans.AddToInventory = true; 241 trans.AddToInventory = true;
242 trans.InventFolder = packet.InventoryBlock.FolderID; 242 trans.InventFolder = packet.InventoryBlock.FolderID;
243 } 243 }
244 } 244 }
245 } 245 }
246 246
247 private class AssetTransaction 247 private class AssetTransaction
248 { 248 {
249 public uint XferID; 249 public uint XferID;
250 public AssetBase Asset; 250 public AssetBase Asset;
251 public bool AddToInventory; 251 public bool AddToInventory;
252 public LLUUID InventFolder = LLUUID.Zero; 252 public LLUUID InventFolder = LLUUID.Zero;
253 public bool UploadComplete = false; 253 public bool UploadComplete = false;
254 public LLUUID TransactionID = LLUUID.Zero; 254 public LLUUID TransactionID = LLUUID.Zero;
255 255
256 public AssetTransaction() 256 public AssetTransaction()
257 { 257 {
258 258
259 } 259 }
260 } 260 }
261 261
262 //new class , not currently used. 262 //new class , not currently used.
263 public class AssetXferUploader 263 public class AssetXferUploader
264 { 264 {
265 private IClientAPI ourClient; 265 private IClientAPI ourClient;
266 266
267 public bool UploadComplete = false; 267 public bool UploadComplete = false;
268 268
269 public bool AddToInventory; 269 public bool AddToInventory;
270 public LLUUID InventFolder = LLUUID.Zero; 270 public LLUUID InventFolder = LLUUID.Zero;
271 271
272 public uint XferID; 272 public uint XferID;
273 public AssetBase Asset; 273 public AssetBase Asset;
274 public LLUUID TransactionID = LLUUID.Zero; 274 public LLUUID TransactionID = LLUUID.Zero;
275 275
276 276
277 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) 277 public AssetXferUploader(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
278 { 278 {
279 ourClient = remoteClient; 279 ourClient = remoteClient;
280 Asset = new AssetBase(); 280 Asset = new AssetBase();
281 Asset.FullID = assetID; 281 Asset.FullID = assetID;
282 Asset.InvType = type; 282 Asset.InvType = type;
283 Asset.Type = type; 283 Asset.Type = type;
284 Asset.Data = data; 284 Asset.Data = data;
285 Asset.Name = "blank"; 285 Asset.Name = "blank";
286 Asset.Description = "empty"; 286 Asset.Description = "empty";
287 TransactionID = transaction; 287 TransactionID = transaction;
288 288
289 if (Asset.Data.Length > 2) 289 if (Asset.Data.Length > 2)
290 { 290 {
291 //data block should only have data in it, if there is no more data to be uploaded 291 //data block should only have data in it, if there is no more data to be uploaded
292 this.SendCompleteMessage(); 292 this.SendCompleteMessage();
293 } 293 }
294 else 294 else
295 { 295 {
296 this.ReqestStartXfer(); 296 this.ReqestStartXfer();
297 } 297 }
298 } 298 }
299 299
300 protected void SendCompleteMessage() 300 protected void SendCompleteMessage()
301 { 301 {
302 UploadComplete = true; 302 UploadComplete = true;
303 AssetUploadCompletePacket response = new AssetUploadCompletePacket(); 303 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
304 response.AssetBlock.Type = Asset.Type; 304 response.AssetBlock.Type = Asset.Type;
305 response.AssetBlock.Success = true; 305 response.AssetBlock.Success = true;
306 response.AssetBlock.UUID = Asset.FullID; 306 response.AssetBlock.UUID = Asset.FullID;
307 this.ourClient.OutPacket(response); 307 this.ourClient.OutPacket(response);
308 308
309 //TODO trigger event 309 //TODO trigger event
310 } 310 }
311 311
312 protected void ReqestStartXfer() 312 protected void ReqestStartXfer()
313 { 313 {
314 UploadComplete = false; 314 UploadComplete = false;
315 XferID = Util.GetNextXferID(); 315 XferID = Util.GetNextXferID();
316 RequestXferPacket xfer = new RequestXferPacket(); 316 RequestXferPacket xfer = new RequestXferPacket();
317 xfer.XferID.ID = XferID; 317 xfer.XferID.ID = XferID;
318 xfer.XferID.VFileType = Asset.Type; 318 xfer.XferID.VFileType = Asset.Type;
319 xfer.XferID.VFileID = Asset.FullID; 319 xfer.XferID.VFileID = Asset.FullID;
320 xfer.XferID.FilePath = 0; 320 xfer.XferID.FilePath = 0;
321 xfer.XferID.Filename = new byte[0]; 321 xfer.XferID.Filename = new byte[0];
322 this.ourClient.OutPacket(xfer); 322 this.ourClient.OutPacket(xfer);
323 } 323 }
324 324
325 public void HandleXferPacket(uint xferID, uint packetID, byte[] data) 325 public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
326 { 326 {
327 if (XferID == xferID) 327 if (XferID == xferID)
328 { 328 {
329 if (Asset.Data.Length > 1) 329 if (Asset.Data.Length > 1)
330 { 330 {
331 byte[] newArray = new byte[Asset.Data.Length + data.Length]; 331 byte[] newArray = new byte[Asset.Data.Length + data.Length];
332 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length); 332 Array.Copy(Asset.Data, 0, newArray, 0, Asset.Data.Length);
333 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length); 333 Array.Copy(data, 0, newArray, Asset.Data.Length, data.Length);
334 Asset.Data = newArray; 334 Asset.Data = newArray;
335 } 335 }
336 else 336 else
337 { 337 {
338 byte[] newArray = new byte[data.Length - 4]; 338 byte[] newArray = new byte[data.Length - 4];
339 Array.Copy(data, 4, newArray, 0, data.Length - 4); 339 Array.Copy(data, 4, newArray, 0, data.Length - 4);
340 Asset.Data = newArray; 340 Asset.Data = newArray;
341 } 341 }
342 342
343 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket(); 343 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
344 confirmXfer.XferID.ID = xferID; 344 confirmXfer.XferID.ID = xferID;
345 confirmXfer.XferID.Packet = packetID; 345 confirmXfer.XferID.Packet = packetID;
346 this.ourClient.OutPacket(confirmXfer); 346 this.ourClient.OutPacket(confirmXfer);
347 347
348 if ((packetID & 2147483648) != 0) 348 if ((packetID & 2147483648) != 0)
349 { 349 {
350 this.SendCompleteMessage(); 350 this.SendCompleteMessage();
351 } 351 }
352 } 352 }
353 } 353 }
354 } 354 }
355 } 355 }
356 } 356 }
357} 357}
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
index e67807e..27265cf 100644
--- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
+++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
@@ -1,236 +1,236 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using libsecondlife; 28using libsecondlife;
29using libsecondlife.Packets; 29using libsecondlife.Packets;
30using OpenSim.Framework.Console; 30using OpenSim.Framework.Console;
31 31
32namespace OpenSim.Region.ClientStack 32namespace OpenSim.Region.ClientStack
33{ 33{
34 public partial class ClientView 34 public partial class ClientView
35 { 35 {
36 protected virtual void RegisterLocalPacketHandlers() 36 protected virtual void RegisterLocalPacketHandlers()
37 { 37 {
38 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); 38 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
39 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); 39 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
40 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); 40 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
41 } 41 }
42 42
43 protected virtual bool Logout(ClientView simClient, Packet packet) 43 protected virtual bool Logout(ClientView simClient, Packet packet)
44 { 44 {
45 MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); 45 MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
46 //send reply to let the client logout 46 //send reply to let the client logout
47 LogoutReplyPacket logReply = new LogoutReplyPacket(); 47 LogoutReplyPacket logReply = new LogoutReplyPacket();
48 logReply.AgentData.AgentID = this.AgentID; 48 logReply.AgentData.AgentID = this.AgentID;
49 logReply.AgentData.SessionID = this.SessionID; 49 logReply.AgentData.SessionID = this.SessionID;
50 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; 50 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
51 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); 51 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
52 logReply.InventoryData[0].ItemID = LLUUID.Zero; 52 logReply.InventoryData[0].ItemID = LLUUID.Zero;
53 OutPacket(logReply); 53 OutPacket(logReply);
54 // 54 //
55 this.KillClient(); 55 this.KillClient();
56 return true; 56 return true;
57 } 57 }
58 58
59 protected bool AgentTextureCached(ClientView simclient, Packet packet) 59 protected bool AgentTextureCached(ClientView simclient, Packet packet)
60 { 60 {
61 // Console.WriteLine(packet.ToString()); 61 // Console.WriteLine(packet.ToString());
62 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; 62 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
63 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); 63 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
64 cachedresp.AgentData.AgentID = this.AgentID; 64 cachedresp.AgentData.AgentID = this.AgentID;
65 cachedresp.AgentData.SessionID = this.SessionID; 65 cachedresp.AgentData.SessionID = this.SessionID;
66 cachedresp.AgentData.SerialNum = this.cachedtextureserial; 66 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
67 this.cachedtextureserial++; 67 this.cachedtextureserial++;
68 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; 68 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
69 for (int i = 0; i < chechedtex.WearableData.Length; i++) 69 for (int i = 0; i < chechedtex.WearableData.Length; i++)
70 { 70 {
71 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 71 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
72 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; 72 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
73 cachedresp.WearableData[i].TextureID = LLUUID.Zero; 73 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
74 cachedresp.WearableData[i].HostName = new byte[0]; 74 cachedresp.WearableData[i].HostName = new byte[0];
75 } 75 }
76 this.OutPacket(cachedresp); 76 this.OutPacket(cachedresp);
77 return true; 77 return true;
78 } 78 }
79 79
80 protected bool MultipleObjUpdate(ClientView simClient, Packet packet) 80 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
81 { 81 {
82 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; 82 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
83 //System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); 83 //System.Console.WriteLine("new multi update packet " + multipleupdate.ToString());
84 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 84 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
85 { 85 {
86 #region position 86 #region position
87 if (multipleupdate.ObjectData[i].Type == 9) //change position 87 if (multipleupdate.ObjectData[i].Type == 9) //change position
88 { 88 {
89 if (OnUpdatePrimGroupPosition != null) 89 if (OnUpdatePrimGroupPosition != null)
90 { 90 {
91 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 91 LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
92 OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 92 OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
93 } 93 }
94 94
95 } 95 }
96 else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position 96 else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position
97 { 97 {
98 if (OnUpdatePrimSinglePosition != null) 98 if (OnUpdatePrimSinglePosition != null)
99 { 99 {
100 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 100 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
101 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 101 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
102 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 102 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
103 } 103 }
104 } 104 }
105 #endregion position 105 #endregion position
106 #region rotation 106 #region rotation
107 else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab 107 else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab
108 { 108 {
109 if (OnUpdatePrimSingleRotation != null) 109 if (OnUpdatePrimSingleRotation != null)
110 { 110 {
111 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); 111 LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
112 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 112 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
113 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 113 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
114 } 114 }
115 } 115 }
116 else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse 116 else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse
117 { 117 {
118 if (OnUpdatePrimSingleRotation != null) 118 if (OnUpdatePrimSingleRotation != null)
119 { 119 {
120 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 120 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
121 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 121 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
122 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 122 OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
123 } 123 }
124 } 124 }
125 else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab 125 else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab
126 { 126 {
127 if (OnUpdatePrimGroupRotation != null) 127 if (OnUpdatePrimGroupRotation != null)
128 { 128 {
129 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); 129 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
130 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 130 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
131 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 131 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
132 } 132 }
133 } 133 }
134 else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse 134 else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse
135 { 135 {
136 if (OnUpdatePrimGroupMouseRotation != null) 136 if (OnUpdatePrimGroupMouseRotation != null)
137 { 137 {
138 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 138 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
139 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 139 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
140 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 140 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
141 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 141 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
142 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); 142 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this);
143 } 143 }
144 } 144 }
145 #endregion 145 #endregion
146 #region scale 146 #region scale
147 else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab 147 else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab
148 { 148 {
149 if (OnUpdatePrimScale != null) 149 if (OnUpdatePrimScale != null)
150 { 150 {
151 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 151 LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
152 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 152 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
153 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 153 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
154 } 154 }
155 } 155 }
156 else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse 156 else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse
157 { 157 {
158 if (OnUpdatePrimScale != null) 158 if (OnUpdatePrimScale != null)
159 { 159 {
160 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 160 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
161 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); 161 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z );
162 // OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 162 // OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
163 } 163 }
164 } 164 }
165 else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab 165 else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab
166 { 166 {
167 if (OnUpdatePrimScale != null) 167 if (OnUpdatePrimScale != null)
168 { 168 {
169 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 169 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
170 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 170 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
171 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 171 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
172 } 172 }
173 } 173 }
174 else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse 174 else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse
175 { 175 {
176 if (OnUpdatePrimScale != null) 176 if (OnUpdatePrimScale != null)
177 { 177 {
178 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 178 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
179 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 179 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
180 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 180 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
181 } 181 }
182 } 182 }
183 #endregion 183 #endregion
184 } 184 }
185 return true; 185 return true;
186 } 186 }
187 187
188 public void RequestMapLayer() 188 public void RequestMapLayer()
189 { 189 {
190 //should be getting the map layer from the grid server 190 //should be getting the map layer from the grid server
191 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) 191 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
192 MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); 192 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
193 mapReply.AgentData.AgentID = this.AgentID; 193 mapReply.AgentData.AgentID = this.AgentID;
194 mapReply.AgentData.Flags = 0; 194 mapReply.AgentData.Flags = 0;
195 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; 195 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
196 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); 196 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
197 mapReply.LayerData[0].Bottom = 0; 197 mapReply.LayerData[0].Bottom = 0;
198 mapReply.LayerData[0].Left = 0; 198 mapReply.LayerData[0].Left = 0;
199 mapReply.LayerData[0].Top = 30000; 199 mapReply.LayerData[0].Top = 30000;
200 mapReply.LayerData[0].Right = 30000; 200 mapReply.LayerData[0].Right = 30000;
201 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); 201 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
202 this.OutPacket(mapReply); 202 this.OutPacket(mapReply);
203 } 203 }
204 204
205 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) 205 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
206 { 206 {
207 /* 207 /*
208 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); 208 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
209 MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); 209 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
210 mbReply.AgentData.AgentID = this.AgentID; 210 mbReply.AgentData.AgentID = this.AgentID;
211 int len; 211 int len;
212 if (simMapProfiles == null) 212 if (simMapProfiles == null)
213 len = 0; 213 len = 0;
214 else 214 else
215 len = simMapProfiles.Count; 215 len = simMapProfiles.Count;
216 216
217 mbReply.Data = new MapBlockReplyPacket.DataBlock[len]; 217 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
218 int iii; 218 int iii;
219 for (iii = 0; iii < len; iii++) 219 for (iii = 0; iii < len; iii++)
220 { 220 {
221 Hashtable mp = (Hashtable)simMapProfiles[iii]; 221 Hashtable mp = (Hashtable)simMapProfiles[iii];
222 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); 222 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
223 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); 223 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
224 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); 224 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
225 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); 225 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
226 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]); 226 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
227 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); 227 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
228 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]); 228 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
229 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]); 229 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
230 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); 230 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
231 } 231 }
232 this.OutPacket(mbReply); 232 this.OutPacket(mbReply);
233 */ 233 */
234 } 234 }
235 } 235 }
236} 236}
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
index a8512a7..1f9110c 100644
--- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -1,647 +1,647 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using libsecondlife; 31using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework.Inventory; 33using OpenSim.Framework.Inventory;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities; 35using OpenSim.Framework.Utilities;
36 36
37namespace OpenSim.Region.ClientStack 37namespace OpenSim.Region.ClientStack
38{ 38{
39 public partial class ClientView 39 public partial class ClientView
40 { 40 {
41 protected override void ProcessInPacket(Packet Pack) 41 protected override void ProcessInPacket(Packet Pack)
42 { 42 {
43 ack_pack(Pack); 43 ack_pack(Pack);
44 if (debug) 44 if (debug)
45 { 45 {
46 if (Pack.Type != PacketType.AgentUpdate) 46 if (Pack.Type != PacketType.AgentUpdate)
47 { 47 {
48 Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString()); 48 Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString());
49 } 49 }
50 } 50 }
51 51
52 if (this.ProcessPacketMethod(Pack)) 52 if (this.ProcessPacketMethod(Pack))
53 { 53 {
54 //there is a handler registered that handled this packet type 54 //there is a handler registered that handled this packet type
55 return; 55 return;
56 } 56 }
57 else 57 else
58 { 58 {
59 Encoding _enc = Encoding.ASCII; 59 Encoding _enc = Encoding.ASCII;
60 60
61 switch (Pack.Type) 61 switch (Pack.Type)
62 { 62 {
63 case PacketType.ViewerEffect: 63 case PacketType.ViewerEffect:
64 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; 64 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
65 foreach (ClientView client in m_clientThreads.Values) 65 foreach (ClientView client in m_clientThreads.Values)
66 { 66 {
67 if (client.AgentID != this.AgentID) 67 if (client.AgentID != this.AgentID)
68 { 68 {
69 viewer.AgentData.AgentID = client.AgentID; 69 viewer.AgentData.AgentID = client.AgentID;
70 viewer.AgentData.SessionID = client.SessionID; 70 viewer.AgentData.SessionID = client.SessionID;
71 client.OutPacket(viewer); 71 client.OutPacket(viewer);
72 } 72 }
73 } 73 }
74 break; 74 break;
75 75
76 #region World/Avatar 76 #region World/Avatar
77 case PacketType.ChatFromViewer: 77 case PacketType.ChatFromViewer:
78 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; 78 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
79 if (Util.FieldToString(inchatpack.ChatData.Message) == "") 79 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
80 { 80 {
81 //empty message so don't bother with it 81 //empty message so don't bother with it
82 break; 82 break;
83 } 83 }
84 string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; 84 string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
85 byte[] message = inchatpack.ChatData.Message; 85 byte[] message = inchatpack.ChatData.Message;
86 byte type = inchatpack.ChatData.Type; 86 byte type = inchatpack.ChatData.Type;
87 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; 87 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos;
88 LLUUID fromAgentID = AgentID; 88 LLUUID fromAgentID = AgentID;
89 if (OnChatFromViewer != null) 89 if (OnChatFromViewer != null)
90 { 90 {
91 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); 91 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
92 } 92 }
93 break; 93 break;
94 case PacketType.ImprovedInstantMessage: 94 case PacketType.ImprovedInstantMessage:
95 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; 95 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
96 96
97 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); 97 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
98 string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); 98 string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message);
99 99
100 if (OnInstantMessage != null) 100 if (OnInstantMessage != null)
101 { 101 {
102 this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID, 102 this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID,
103 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage); 103 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage);
104 } 104 }
105 break; 105 break;
106 case PacketType.RezObject: 106 case PacketType.RezObject:
107 RezObjectPacket rezPacket = (RezObjectPacket)Pack; 107 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
108 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID); 108 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
109 if (inven != null) 109 if (inven != null)
110 { 110 {
111 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) 111 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
112 { 112 {
113 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); 113 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
114 if (asset != null) 114 if (asset != null)
115 { 115 {
116 if (OnRezObject != null) 116 if (OnRezObject != null)
117 { 117 {
118 this.OnRezObject(asset, rezPacket.RezData.RayEnd); 118 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
119 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID); 119 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
120 } 120 }
121 } 121 }
122 } 122 }
123 } 123 }
124 break; 124 break;
125 case PacketType.DeRezObject: 125 case PacketType.DeRezObject:
126 if (OnDeRezObject != null) 126 if (OnDeRezObject != null)
127 { 127 {
128 OnDeRezObject(Pack, this); 128 OnDeRezObject(Pack, this);
129 } 129 }
130 break; 130 break;
131 case PacketType.ModifyLand: 131 case PacketType.ModifyLand:
132 ModifyLandPacket modify = (ModifyLandPacket)Pack; 132 ModifyLandPacket modify = (ModifyLandPacket)Pack;
133 if (modify.ParcelData.Length > 0) 133 if (modify.ParcelData.Length > 0)
134 { 134 {
135 if (OnModifyTerrain != null) 135 if (OnModifyTerrain != null)
136 { 136 {
137 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, 137 OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize,
138 modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); 138 modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
139 } 139 }
140 } 140 }
141 break; 141 break;
142 case PacketType.RegionHandshakeReply: 142 case PacketType.RegionHandshakeReply:
143 if (OnRegionHandShakeReply != null) 143 if (OnRegionHandShakeReply != null)
144 { 144 {
145 OnRegionHandShakeReply(this); 145 OnRegionHandShakeReply(this);
146 } 146 }
147 break; 147 break;
148 case PacketType.AgentWearablesRequest: 148 case PacketType.AgentWearablesRequest:
149 if (OnRequestWearables != null) 149 if (OnRequestWearables != null)
150 { 150 {
151 OnRequestWearables(this); 151 OnRequestWearables(this);
152 } 152 }
153 if (OnRequestAvatarsData != null) 153 if (OnRequestAvatarsData != null)
154 { 154 {
155 OnRequestAvatarsData(this); 155 OnRequestAvatarsData(this);
156 } 156 }
157 break; 157 break;
158 case PacketType.AgentSetAppearance: 158 case PacketType.AgentSetAppearance:
159 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; 159 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
160 if (OnSetAppearance != null) 160 if (OnSetAppearance != null)
161 { 161 {
162 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); 162 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
163 } 163 }
164 break; 164 break;
165 case PacketType.CompleteAgentMovement: 165 case PacketType.CompleteAgentMovement:
166 if (OnCompleteMovementToRegion != null) 166 if (OnCompleteMovementToRegion != null)
167 { 167 {
168 OnCompleteMovementToRegion(); 168 OnCompleteMovementToRegion();
169 } 169 }
170 break; 170 break;
171 case PacketType.AgentUpdate: 171 case PacketType.AgentUpdate:
172 if (OnAgentUpdate != null) 172 if (OnAgentUpdate != null)
173 { 173 {
174 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; 174 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
175 OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); 175 OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation);
176 } 176 }
177 break; 177 break;
178 case PacketType.AgentAnimation: 178 case PacketType.AgentAnimation:
179 if (!m_child) 179 if (!m_child)
180 { 180 {
181 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; 181 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
182 for (int i = 0; i < AgentAni.AnimationList.Length; i++) 182 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
183 { 183 {
184 if (AgentAni.AnimationList[i].StartAnim) 184 if (AgentAni.AnimationList[i].StartAnim)
185 { 185 {
186 if (OnStartAnim != null) 186 if (OnStartAnim != null)
187 { 187 {
188 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1); 188 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193 break; 193 break;
194 194
195 #endregion 195 #endregion
196 196
197 #region Objects/Prims 197 #region Objects/Prims
198 case PacketType.ObjectLink: 198 case PacketType.ObjectLink:
199 // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); 199 // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
200 ObjectLinkPacket link = (ObjectLinkPacket)Pack; 200 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
201 uint parentprimid = 0; 201 uint parentprimid = 0;
202 List<uint> childrenprims = new List<uint>(); 202 List<uint> childrenprims = new List<uint>();
203 if (link.ObjectData.Length > 1) 203 if (link.ObjectData.Length > 1)
204 { 204 {
205 parentprimid = link.ObjectData[0].ObjectLocalID; 205 parentprimid = link.ObjectData[0].ObjectLocalID;
206 206
207 for (int i = 1; i < link.ObjectData.Length; i++) 207 for (int i = 1; i < link.ObjectData.Length; i++)
208 { 208 {
209 childrenprims.Add(link.ObjectData[i].ObjectLocalID); 209 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
210 } 210 }
211 } 211 }
212 if (OnLinkObjects != null) 212 if (OnLinkObjects != null)
213 { 213 {
214 OnLinkObjects(parentprimid, childrenprims); 214 OnLinkObjects(parentprimid, childrenprims);
215 } 215 }
216 break; 216 break;
217 case PacketType.ObjectAdd: 217 case PacketType.ObjectAdd:
218 if (OnAddPrim != null) 218 if (OnAddPrim != null)
219 { 219 {
220 ObjectAddPacket addPacket = (ObjectAddPacket) Pack ; 220 ObjectAddPacket addPacket = (ObjectAddPacket) Pack ;
221 221
222 PrimitiveBaseShape shape = new PrimitiveBaseShape(); 222 PrimitiveBaseShape shape = new PrimitiveBaseShape();
223 223
224 shape.PCode = addPacket.ObjectData.PCode; 224 shape.PCode = addPacket.ObjectData.PCode;
225 shape.PathBegin = addPacket.ObjectData.PathBegin; 225 shape.PathBegin = addPacket.ObjectData.PathBegin;
226 shape.PathEnd = addPacket.ObjectData.PathEnd; 226 shape.PathEnd = addPacket.ObjectData.PathEnd;
227 shape.PathScaleX = addPacket.ObjectData.PathScaleX; 227 shape.PathScaleX = addPacket.ObjectData.PathScaleX;
228 shape.PathScaleY = addPacket.ObjectData.PathScaleY; 228 shape.PathScaleY = addPacket.ObjectData.PathScaleY;
229 shape.PathShearX = addPacket.ObjectData.PathShearX; 229 shape.PathShearX = addPacket.ObjectData.PathShearX;
230 shape.PathShearY = addPacket.ObjectData.PathShearY; 230 shape.PathShearY = addPacket.ObjectData.PathShearY;
231 shape.PathSkew = addPacket.ObjectData.PathSkew; 231 shape.PathSkew = addPacket.ObjectData.PathSkew;
232 shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; 232 shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
233 shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; 233 shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
234 shape.Scale = addPacket.ObjectData.Scale; 234 shape.Scale = addPacket.ObjectData.Scale;
235 shape.PathCurve = addPacket.ObjectData.PathCurve; 235 shape.PathCurve = addPacket.ObjectData.PathCurve;
236 shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; 236 shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
237 shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; 237 shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
238 shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; 238 shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
239 shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; 239 shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
240 shape.PathTaperX = addPacket.ObjectData.PathTaperX; 240 shape.PathTaperX = addPacket.ObjectData.PathTaperX;
241 shape.PathTaperY = addPacket.ObjectData.PathTaperY; 241 shape.PathTaperY = addPacket.ObjectData.PathTaperY;
242 shape.PathTwist = addPacket.ObjectData.PathTwist; 242 shape.PathTwist = addPacket.ObjectData.PathTwist;
243 shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; 243 shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
244 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); 244 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005"));
245 shape.TextureEntry = ntex.ToBytes(); 245 shape.TextureEntry = ntex.ToBytes();
246 246
247 OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape); 247 OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape);
248 } 248 }
249 break; 249 break;
250 case PacketType.ObjectShape: 250 case PacketType.ObjectShape:
251 ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; 251 ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
252 for (int i = 0; i < shapePacket.ObjectData.Length; i++) 252 for (int i = 0; i < shapePacket.ObjectData.Length; i++)
253 { 253 {
254 if (OnUpdatePrimShape != null) 254 if (OnUpdatePrimShape != null)
255 { 255 {
256 OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); 256 OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]);
257 } 257 }
258 } 258 }
259 break; 259 break;
260 case PacketType.ObjectDuplicate: 260 case PacketType.ObjectDuplicate:
261 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; 261 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
262 for (int i = 0; i < dupe.ObjectData.Length; i++) 262 for (int i = 0; i < dupe.ObjectData.Length; i++)
263 { 263 {
264 if (OnObjectDuplicate != null) 264 if (OnObjectDuplicate != null)
265 { 265 {
266 OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); 266 OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags);
267 } 267 }
268 } 268 }
269 269
270 break; 270 break;
271 271
272 case PacketType.ObjectSelect: 272 case PacketType.ObjectSelect:
273 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; 273 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
274 for (int i = 0; i < incomingselect.ObjectData.Length; i++) 274 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
275 { 275 {
276 if (OnObjectSelect != null) 276 if (OnObjectSelect != null)
277 { 277 {
278 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); 278 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
279 } 279 }
280 } 280 }
281 break; 281 break;
282 case PacketType.ObjectDeselect: 282 case PacketType.ObjectDeselect:
283 ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; 283 ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
284 for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) 284 for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
285 { 285 {
286 if (OnObjectDeselect != null) 286 if (OnObjectDeselect != null)
287 { 287 {
288 OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); 288 OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
289 } 289 }
290 } 290 }
291 break; 291 break;
292 case PacketType.ObjectFlagUpdate: 292 case PacketType.ObjectFlagUpdate:
293 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; 293 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
294 if (OnUpdatePrimFlags != null) 294 if (OnUpdatePrimFlags != null)
295 { 295 {
296 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); 296 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
297 } 297 }
298 break; 298 break;
299 case PacketType.ObjectImage: 299 case PacketType.ObjectImage:
300 ObjectImagePacket imagePack = (ObjectImagePacket)Pack; 300 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
301 for (int i = 0; i < imagePack.ObjectData.Length; i++) 301 for (int i = 0; i < imagePack.ObjectData.Length; i++)
302 { 302 {
303 if (OnUpdatePrimTexture != null) 303 if (OnUpdatePrimTexture != null)
304 { 304 {
305 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); 305 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this);
306 } 306 }
307 } 307 }
308 break; 308 break;
309 case PacketType.ObjectGrab: 309 case PacketType.ObjectGrab:
310 ObjectGrabPacket grap = (ObjectGrabPacket)Pack; 310 ObjectGrabPacket grap = (ObjectGrabPacket)Pack;
311 if (OnGrapObject != null) 311 if (OnGrapObject != null)
312 { 312 {
313 OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this); 313 OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this);
314 } 314 }
315 break; 315 break;
316 case PacketType.ObjectGrabUpdate: 316 case PacketType.ObjectGrabUpdate:
317 ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack; 317 ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack;
318 if (OnGrapUpdate != null) 318 if (OnGrapUpdate != null)
319 { 319 {
320 OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this); 320 OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this);
321 } 321 }
322 break; 322 break;
323 case PacketType.ObjectDeGrab: 323 case PacketType.ObjectDeGrab:
324 ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack; 324 ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack;
325 if (OnDeGrapObject != null) 325 if (OnDeGrapObject != null)
326 { 326 {
327 OnDeGrapObject(deGrap.ObjectData.LocalID, this); 327 OnDeGrapObject(deGrap.ObjectData.LocalID, this);
328 } 328 }
329 break; 329 break;
330 case PacketType.ObjectDescription: 330 case PacketType.ObjectDescription:
331 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; 331 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
332 for (int i = 0; i < objDes.ObjectData.Length; i++) 332 for (int i = 0; i < objDes.ObjectData.Length; i++)
333 { 333 {
334 if (OnObjectDescription != null) 334 if (OnObjectDescription != null)
335 { 335 {
336 OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); 336 OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description));
337 } 337 }
338 } 338 }
339 break; 339 break;
340 case PacketType.ObjectName: 340 case PacketType.ObjectName:
341 ObjectNamePacket objName = (ObjectNamePacket)Pack; 341 ObjectNamePacket objName = (ObjectNamePacket)Pack;
342 for (int i = 0; i < objName.ObjectData.Length; i++) 342 for (int i = 0; i < objName.ObjectData.Length; i++)
343 { 343 {
344 if (OnObjectName != null) 344 if (OnObjectName != null)
345 { 345 {
346 OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); 346 OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name));
347 } 347 }
348 } 348 }
349 break; 349 break;
350 case PacketType.ObjectPermissions: 350 case PacketType.ObjectPermissions:
351 //Console.WriteLine("permissions set " + Pack.ToString()); 351 //Console.WriteLine("permissions set " + Pack.ToString());
352 break; 352 break;
353 #endregion 353 #endregion
354 354
355 #region Inventory/Asset/Other related packets 355 #region Inventory/Asset/Other related packets
356 case PacketType.RequestImage: 356 case PacketType.RequestImage:
357 RequestImagePacket imageRequest = (RequestImagePacket)Pack; 357 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
358 for (int i = 0; i < imageRequest.RequestImage.Length; i++) 358 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
359 { 359 {
360 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); 360 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
361 } 361 }
362 break; 362 break;
363 case PacketType.TransferRequest: 363 case PacketType.TransferRequest:
364 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); 364 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
365 TransferRequestPacket transfer = (TransferRequestPacket)Pack; 365 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
366 m_assetCache.AddAssetRequest(this, transfer); 366 m_assetCache.AddAssetRequest(this, transfer);
367 break; 367 break;
368 case PacketType.AssetUploadRequest: 368 case PacketType.AssetUploadRequest:
369 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; 369 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
370 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); 370 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
371 break; 371 break;
372 case PacketType.RequestXfer: 372 case PacketType.RequestXfer:
373 //Console.WriteLine(Pack.ToString()); 373 //Console.WriteLine(Pack.ToString());
374 break; 374 break;
375 case PacketType.SendXferPacket: 375 case PacketType.SendXferPacket:
376 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); 376 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
377 break; 377 break;
378 case PacketType.CreateInventoryFolder: 378 case PacketType.CreateInventoryFolder:
379 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; 379 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
380 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); 380 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
381 //Console.WriteLine(Pack.ToString()); 381 //Console.WriteLine(Pack.ToString());
382 break; 382 break;
383 case PacketType.CreateInventoryItem: 383 case PacketType.CreateInventoryItem:
384 //Console.WriteLine(Pack.ToString()); 384 //Console.WriteLine(Pack.ToString());
385 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; 385 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
386 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) 386 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
387 { 387 {
388 this.UploadAssets.CreateInventoryItem(createItem); 388 this.UploadAssets.CreateInventoryItem(createItem);
389 } 389 }
390 else 390 else
391 { 391 {
392 // Console.Write(Pack.ToString()); 392 // Console.Write(Pack.ToString());
393 this.CreateInventoryItem(createItem); 393 this.CreateInventoryItem(createItem);
394 } 394 }
395 break; 395 break;
396 case PacketType.FetchInventory: 396 case PacketType.FetchInventory:
397 //Console.WriteLine("fetch item packet"); 397 //Console.WriteLine("fetch item packet");
398 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; 398 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
399 m_inventoryCache.FetchInventory(this, FetchInventory); 399 m_inventoryCache.FetchInventory(this, FetchInventory);
400 break; 400 break;
401 case PacketType.FetchInventoryDescendents: 401 case PacketType.FetchInventoryDescendents:
402 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; 402 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
403 m_inventoryCache.FetchInventoryDescendents(this, Fetch); 403 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
404 break; 404 break;
405 case PacketType.UpdateInventoryItem: 405 case PacketType.UpdateInventoryItem:
406 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; 406 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
407 //Console.WriteLine(Pack.ToString()); 407 //Console.WriteLine(Pack.ToString());
408 for (int i = 0; i < update.InventoryData.Length; i++) 408 for (int i = 0; i < update.InventoryData.Length; i++)
409 { 409 {
410 if (update.InventoryData[i].TransactionID != LLUUID.Zero) 410 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
411 { 411 {
412 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); 412 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
413 if (asset != null) 413 if (asset != null)
414 { 414 {
415 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); 415 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
416 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); 416 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
417 } 417 }
418 else 418 else
419 { 419 {
420 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); 420 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
421 if (asset != null) 421 if (asset != null)
422 { 422 {
423 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); 423 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
424 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); 424 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
425 } 425 }
426 else 426 else
427 { 427 {
428 //Console.WriteLine("trying to update inventory item, but asset is null"); 428 //Console.WriteLine("trying to update inventory item, but asset is null");
429 } 429 }
430 } 430 }
431 } 431 }
432 else 432 else
433 { 433 {
434 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; 434 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
435 } 435 }
436 } 436 }
437 break; 437 break;
438 case PacketType.RequestTaskInventory: 438 case PacketType.RequestTaskInventory:
439 // Console.WriteLine(Pack.ToString()); 439 // Console.WriteLine(Pack.ToString());
440 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; 440 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
441 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); 441 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
442 //bool foundent = false; 442 //bool foundent = false;
443 /* foreach (Entity ent in m_world.Entities.Values) 443 /* foreach (Entity ent in m_world.Entities.Values)
444 { 444 {
445 if (ent.localid == requesttask.InventoryData.LocalID) 445 if (ent.localid == requesttask.InventoryData.LocalID)
446 { 446 {
447 replytask.InventoryData.TaskID = ent.uuid; 447 replytask.InventoryData.TaskID = ent.uuid;
448 replytask.InventoryData.Serial = 0; 448 replytask.InventoryData.Serial = 0;
449 replytask.InventoryData.Filename = new byte[0]; 449 replytask.InventoryData.Filename = new byte[0];
450 foundent = true; 450 foundent = true;
451 } 451 }
452 } 452 }
453 if (foundent) 453 if (foundent)
454 { 454 {
455 this.OutPacket(replytask); 455 this.OutPacket(replytask);
456 }*/ 456 }*/
457 break; 457 break;
458 case PacketType.UpdateTaskInventory: 458 case PacketType.UpdateTaskInventory:
459 // Console.WriteLine(Pack.ToString()); 459 // Console.WriteLine(Pack.ToString());
460 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; 460 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
461 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); 461 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
462 /*if (myinventory != null) 462 /*if (myinventory != null)
463 { 463 {
464 if (updatetask.UpdateData.Key == 0) 464 if (updatetask.UpdateData.Key == 0)
465 { 465 {
466 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) 466 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
467 { 467 {
468 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) 468 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
469 { 469 {
470 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; 470 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
471 AssetBase assBase = this.m_assetCache.GetAsset(noteaid); 471 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
472 if (assBase != null) 472 if (assBase != null)
473 { 473 {
474 foreach (Entity ent in m_world.Entities.Values) 474 foreach (Entity ent in m_world.Entities.Values)
475 { 475 {
476 if (ent.localid == updatetask.UpdateData.LocalID) 476 if (ent.localid == updatetask.UpdateData.LocalID)
477 { 477 {
478 if (ent is OpenSim.world.Primitive) 478 if (ent is OpenSim.world.Primitive)
479 { 479 {
480 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); 480 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
481 } 481 }
482 } 482 }
483 } 483 }
484 } 484 }
485 } 485 }
486 } 486 }
487 } 487 }
488 }*/ 488 }*/
489 break; 489 break;
490 case PacketType.MapLayerRequest: 490 case PacketType.MapLayerRequest:
491 this.RequestMapLayer(); 491 this.RequestMapLayer();
492 break; 492 break;
493 case PacketType.MapBlockRequest: 493 case PacketType.MapBlockRequest:
494 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; 494 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
495 if (OnRequestMapBlocks != null) 495 if (OnRequestMapBlocks != null)
496 { 496 {
497 OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); 497 OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
498 } 498 }
499 break; 499 break;
500 case PacketType.TeleportLandmarkRequest: 500 case PacketType.TeleportLandmarkRequest:
501 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; 501 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
502 502
503 TeleportStartPacket tpStart = new TeleportStartPacket(); 503 TeleportStartPacket tpStart = new TeleportStartPacket();
504 tpStart.Info.TeleportFlags = 8; // tp via lm 504 tpStart.Info.TeleportFlags = 8; // tp via lm
505 this.OutPacket(tpStart); 505 this.OutPacket(tpStart);
506 506
507 TeleportProgressPacket tpProgress = new TeleportProgressPacket(); 507 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
508 tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); 508 tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark");
509 tpProgress.Info.TeleportFlags = 8; 509 tpProgress.Info.TeleportFlags = 8;
510 tpProgress.AgentData.AgentID = tpReq.Info.AgentID; 510 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
511 this.OutPacket(tpProgress); 511 this.OutPacket(tpProgress);
512 512
513 // Fetch landmark 513 // Fetch landmark
514 LLUUID lmid = tpReq.Info.LandmarkID; 514 LLUUID lmid = tpReq.Info.LandmarkID;
515 AssetBase lma = this.m_assetCache.GetAsset(lmid); 515 AssetBase lma = this.m_assetCache.GetAsset(lmid);
516 if (lma != null) 516 if (lma != null)
517 { 517 {
518 AssetLandmark lm = new AssetLandmark(lma); 518 AssetLandmark lm = new AssetLandmark(lma);
519 519
520 if (lm.RegionID == m_world.RegionInfo.SimUUID) 520 if (lm.RegionID == m_world.RegionInfo.SimUUID)
521 { 521 {
522 TeleportLocalPacket tpLocal = new TeleportLocalPacket(); 522 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
523 523
524 tpLocal.Info.AgentID = tpReq.Info.AgentID; 524 tpLocal.Info.AgentID = tpReq.Info.AgentID;
525 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark 525 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
526 tpLocal.Info.LocationID = 2; 526 tpLocal.Info.LocationID = 2;
527 tpLocal.Info.Position = lm.Position; 527 tpLocal.Info.Position = lm.Position;
528 OutPacket(tpLocal); 528 OutPacket(tpLocal);
529 } 529 }
530 else 530 else
531 { 531 {
532 TeleportCancelPacket tpCancel = new TeleportCancelPacket(); 532 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
533 tpCancel.Info.AgentID = tpReq.Info.AgentID; 533 tpCancel.Info.AgentID = tpReq.Info.AgentID;
534 tpCancel.Info.SessionID = tpReq.Info.SessionID; 534 tpCancel.Info.SessionID = tpReq.Info.SessionID;
535 OutPacket(tpCancel); 535 OutPacket(tpCancel);
536 } 536 }
537 } 537 }
538 else 538 else
539 { 539 {
540 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); 540 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
541 541
542 TeleportCancelPacket tpCancel = new TeleportCancelPacket(); 542 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
543 tpCancel.Info.AgentID = tpReq.Info.AgentID; 543 tpCancel.Info.AgentID = tpReq.Info.AgentID;
544 tpCancel.Info.SessionID = tpReq.Info.SessionID; 544 tpCancel.Info.SessionID = tpReq.Info.SessionID;
545 OutPacket(tpCancel); 545 OutPacket(tpCancel);
546 } 546 }
547 break; 547 break;
548 case PacketType.TeleportLocationRequest: 548 case PacketType.TeleportLocationRequest:
549 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; 549 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
550 // Console.WriteLine(tpLocReq.ToString()); 550 // Console.WriteLine(tpLocReq.ToString());
551 551
552 if (OnTeleportLocationRequest != null) 552 if (OnTeleportLocationRequest != null)
553 { 553 {
554 OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); 554 OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16);
555 } 555 }
556 else 556 else
557 { 557 {
558 //no event handler so cancel request 558 //no event handler so cancel request
559 TeleportCancelPacket tpCancel = new TeleportCancelPacket(); 559 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
560 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; 560 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
561 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; 561 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
562 OutPacket(tpCancel); 562 OutPacket(tpCancel);
563 } 563 }
564 break; 564 break;
565 #endregion 565 #endregion
566 566
567 case PacketType.MoneyBalanceRequest: 567 case PacketType.MoneyBalanceRequest:
568 this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000); 568 this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000);
569 break; 569 break;
570 case PacketType.UUIDNameRequest: 570 case PacketType.UUIDNameRequest:
571 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; 571 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
572 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) 572 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
573 { 573 {
574 OnNameFromUUIDRequest(UUIDBlock.ID, this); 574 OnNameFromUUIDRequest(UUIDBlock.ID, this);
575 } 575 }
576 break; 576 break;
577 #region Parcel related packets 577 #region Parcel related packets
578 case PacketType.ParcelPropertiesRequest: 578 case PacketType.ParcelPropertiesRequest:
579 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; 579 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
580 if (OnParcelPropertiesRequest != null) 580 if (OnParcelPropertiesRequest != null)
581 { 581 {
582 OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); 582 OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this);
583 } 583 }
584 break; 584 break;
585 case PacketType.ParcelDivide: 585 case PacketType.ParcelDivide:
586 ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack; 586 ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack;
587 if (OnParcelDivideRequest != null) 587 if (OnParcelDivideRequest != null)
588 { 588 {
589 OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this); 589 OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this);
590 } 590 }
591 break; 591 break;
592 case PacketType.ParcelJoin: 592 case PacketType.ParcelJoin:
593 ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack; 593 ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack;
594 if (OnParcelJoinRequest != null) 594 if (OnParcelJoinRequest != null)
595 { 595 {
596 OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this); 596 OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this);
597 } 597 }
598 break; 598 break;
599 case PacketType.ParcelPropertiesUpdate: 599 case PacketType.ParcelPropertiesUpdate:
600 ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; 600 ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack;
601 if (OnParcelPropertiesUpdateRequest != null) 601 if (OnParcelPropertiesUpdateRequest != null)
602 { 602 {
603 OnParcelPropertiesUpdateRequest(updatePacket, this); 603 OnParcelPropertiesUpdateRequest(updatePacket, this);
604 604
605 } 605 }
606 break; 606 break;
607 case PacketType.ParcelSelectObjects: 607 case PacketType.ParcelSelectObjects:
608 ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; 608 ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
609 if (OnParcelSelectObjects != null) 609 if (OnParcelSelectObjects != null)
610 { 610 {
611 OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); 611 OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this);
612 } 612 }
613 break; 613 break;
614 614
615 case PacketType.ParcelObjectOwnersRequest: 615 case PacketType.ParcelObjectOwnersRequest:
616 ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; 616 ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
617 if (OnParcelObjectOwnerRequest != null) 617 if (OnParcelObjectOwnerRequest != null)
618 { 618 {
619 OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); 619 OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
620 } 620 }
621 break; 621 break;
622 #endregion 622 #endregion
623 623
624 #region Estate Packets 624 #region Estate Packets
625 case PacketType.EstateOwnerMessage: 625 case PacketType.EstateOwnerMessage:
626 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; 626 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
627 if (OnEstateOwnerMessage != null) 627 if (OnEstateOwnerMessage != null)
628 { 628 {
629 OnEstateOwnerMessage(messagePacket, this); 629 OnEstateOwnerMessage(messagePacket, this);
630 } 630 }
631 break; 631 break;
632 #endregion 632 #endregion
633 633
634 #region unimplemented handlers 634 #region unimplemented handlers
635 case PacketType.AgentIsNowWearing: 635 case PacketType.AgentIsNowWearing:
636 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; 636 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
637 //Console.WriteLine(Pack.ToString()); 637 //Console.WriteLine(Pack.ToString());
638 break; 638 break;
639 case PacketType.ObjectScale: 639 case PacketType.ObjectScale:
640 //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); 640 //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
641 break; 641 break;
642 #endregion 642 #endregion
643 } 643 }
644 } 644 }
645 } 645 }
646 } 646 }
647} 647}
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 0fe3884..9fddc7b 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -1,293 +1,293 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Text; 31using System.Text;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using libsecondlife; 34using libsecondlife;
35using libsecondlife.Packets; 35using libsecondlife.Packets;
36using OpenSim.Assets; 36using OpenSim.Assets;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
39using OpenSim.Framework.Interfaces; 39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Inventory; 40using OpenSim.Framework.Inventory;
41using OpenSim.Framework.Types; 41using OpenSim.Framework.Types;
42using OpenSim.Framework.Utilities; 42using OpenSim.Framework.Utilities;
43using OpenSim.Region.Caches; 43using OpenSim.Region.Caches;
44using Timer=System.Timers.Timer; 44using Timer=System.Timers.Timer;
45 45
46namespace OpenSim.Region.ClientStack 46namespace OpenSim.Region.ClientStack
47{ 47{
48 public delegate bool PacketMethod(ClientView simClient, Packet packet); 48 public delegate bool PacketMethod(ClientView simClient, Packet packet);
49 49
50 /// <summary> 50 /// <summary>
51 /// Handles new client connections 51 /// Handles new client connections
52 /// Constructor takes a single Packet and authenticates everything 52 /// Constructor takes a single Packet and authenticates everything
53 /// </summary> 53 /// </summary>
54 public partial class ClientView : ClientViewBase, IClientAPI 54 public partial class ClientView : ClientViewBase, IClientAPI
55 { 55 {
56 public static TerrainManager TerrainManager; 56 public static TerrainManager TerrainManager;
57 57
58 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients 58 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
59 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance 59 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance
60 60
61 public LLUUID AgentID; 61 public LLUUID AgentID;
62 public LLUUID SessionID; 62 public LLUUID SessionID;
63 public LLUUID SecureSessionID = LLUUID.Zero; 63 public LLUUID SecureSessionID = LLUUID.Zero;
64 public string firstName; 64 public string firstName;
65 public string lastName; 65 public string lastName;
66 public bool m_child = false; 66 public bool m_child = false;
67 private UseCircuitCodePacket cirpack; 67 private UseCircuitCodePacket cirpack;
68 public Thread ClientThread; 68 public Thread ClientThread;
69 public LLVector3 startpos; 69 public LLVector3 startpos;
70 70
71 private AgentAssetUpload UploadAssets; 71 private AgentAssetUpload UploadAssets;
72 private LLUUID newAssetFolder = LLUUID.Zero; 72 private LLUUID newAssetFolder = LLUUID.Zero;
73 private bool debug = false; 73 private bool debug = false;
74 protected IWorld m_world; 74 protected IWorld m_world;
75 private Dictionary<uint, ClientView> m_clientThreads; 75 private Dictionary<uint, ClientView> m_clientThreads;
76 private AssetCache m_assetCache; 76 private AssetCache m_assetCache;
77 private InventoryCache m_inventoryCache; 77 private InventoryCache m_inventoryCache;
78 private int cachedtextureserial = 0; 78 private int cachedtextureserial = 0;
79 protected AuthenticateSessionsBase m_authenticateSessionsHandler; 79 protected AuthenticateSessionsBase m_authenticateSessionsHandler;
80 private Encoding enc = Encoding.ASCII; 80 private Encoding enc = Encoding.ASCII;
81 // Dead client detection vars 81 // Dead client detection vars
82 private Timer clientPingTimer; 82 private Timer clientPingTimer;
83 private int packetsReceived = 0; 83 private int packetsReceived = 0;
84 private int probesWithNoIngressPackets = 0; 84 private int probesWithNoIngressPackets = 0;
85 private int lastPacketsReceived = 0; 85 private int lastPacketsReceived = 0;
86 86
87 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) 87 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions )
88 { 88 {
89 m_world = world; 89 m_world = world;
90 m_clientThreads = clientThreads; 90 m_clientThreads = clientThreads;
91 m_assetCache = assetCache; 91 m_assetCache = assetCache;
92 92
93 m_networkServer = packServer; 93 m_networkServer = packServer;
94 m_inventoryCache = inventoryCache; 94 m_inventoryCache = inventoryCache;
95 m_authenticateSessionsHandler = authenSessions; 95 m_authenticateSessionsHandler = authenSessions;
96 96
97 MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request"); 97 MainLog.Instance.Verbose( "OpenSimClient.cs - Started up new client thread to handle incoming request");
98 cirpack = initialcirpack; 98 cirpack = initialcirpack;
99 userEP = remoteEP; 99 userEP = remoteEP;
100 100
101 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); 101 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code);
102 102
103 PacketQueue = new BlockingQueue<QueItem>(); 103 PacketQueue = new BlockingQueue<QueItem>();
104 104
105 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); 105 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
106 AckTimer = new Timer(500); 106 AckTimer = new Timer(500);
107 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); 107 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
108 AckTimer.Start(); 108 AckTimer.Start();
109 109
110 this.RegisterLocalPacketHandlers(); 110 this.RegisterLocalPacketHandlers();
111 111
112 ClientThread = new Thread(new ThreadStart(AuthUser)); 112 ClientThread = new Thread(new ThreadStart(AuthUser));
113 ClientThread.IsBackground = true; 113 ClientThread.IsBackground = true;
114 ClientThread.Start(); 114 ClientThread.Start();
115 } 115 }
116 116
117 # region Client Methods 117 # region Client Methods
118 118
119 public void KillClient() 119 public void KillClient()
120 { 120 {
121 clientPingTimer.Stop(); 121 clientPingTimer.Stop();
122 this.m_inventoryCache.ClientLeaving(this.AgentID, null); 122 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
123 m_world.RemoveClient(this.AgentId); 123 m_world.RemoveClient(this.AgentId);
124 124
125 m_clientThreads.Remove(this.CircuitCode); 125 m_clientThreads.Remove(this.CircuitCode);
126 m_networkServer.RemoveClientCircuit(this.CircuitCode); 126 m_networkServer.RemoveClientCircuit(this.CircuitCode);
127 this.ClientThread.Abort(); 127 this.ClientThread.Abort();
128 } 128 }
129 #endregion 129 #endregion
130 130
131 # region Packet Handling 131 # region Packet Handling
132 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) 132 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
133 { 133 {
134 bool result = false; 134 bool result = false;
135 lock (PacketHandlers) 135 lock (PacketHandlers)
136 { 136 {
137 if (!PacketHandlers.ContainsKey(packetType)) 137 if (!PacketHandlers.ContainsKey(packetType))
138 { 138 {
139 PacketHandlers.Add(packetType, handler); 139 PacketHandlers.Add(packetType, handler);
140 result = true; 140 result = true;
141 } 141 }
142 } 142 }
143 return result; 143 return result;
144 } 144 }
145 145
146 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) 146 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
147 { 147 {
148 bool result = false; 148 bool result = false;
149 lock (m_packetHandlers) 149 lock (m_packetHandlers)
150 { 150 {
151 if (!m_packetHandlers.ContainsKey(packetType)) 151 if (!m_packetHandlers.ContainsKey(packetType))
152 { 152 {
153 m_packetHandlers.Add(packetType, handler); 153 m_packetHandlers.Add(packetType, handler);
154 result = true; 154 result = true;
155 } 155 }
156 } 156 }
157 return result; 157 return result;
158 } 158 }
159 159
160 protected virtual bool ProcessPacketMethod(Packet packet) 160 protected virtual bool ProcessPacketMethod(Packet packet)
161 { 161 {
162 bool result = false; 162 bool result = false;
163 bool found = false; 163 bool found = false;
164 PacketMethod method; 164 PacketMethod method;
165 if (m_packetHandlers.TryGetValue(packet.Type, out method)) 165 if (m_packetHandlers.TryGetValue(packet.Type, out method))
166 { 166 {
167 //there is a local handler for this packet type 167 //there is a local handler for this packet type
168 result = method(this, packet); 168 result = method(this, packet);
169 } 169 }
170 else 170 else
171 { 171 {
172 //there is not a local handler so see if there is a Global handler 172 //there is not a local handler so see if there is a Global handler
173 lock (PacketHandlers) 173 lock (PacketHandlers)
174 { 174 {
175 found = PacketHandlers.TryGetValue(packet.Type, out method); 175 found = PacketHandlers.TryGetValue(packet.Type, out method);
176 } 176 }
177 if (found) 177 if (found)
178 { 178 {
179 result = method(this, packet); 179 result = method(this, packet);
180 } 180 }
181 } 181 }
182 return result; 182 return result;
183 } 183 }
184 184
185 protected virtual void ClientLoop() 185 protected virtual void ClientLoop()
186 { 186 {
187 MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop"); 187 MainLog.Instance.Verbose( "OpenSimClient.cs:ClientLoop() - Entered loop");
188 while (true) 188 while (true)
189 { 189 {
190 QueItem nextPacket = PacketQueue.Dequeue(); 190 QueItem nextPacket = PacketQueue.Dequeue();
191 if (nextPacket.Incoming) 191 if (nextPacket.Incoming)
192 { 192 {
193 //is a incoming packet 193 //is a incoming packet
194 if (nextPacket.Packet.Type != PacketType.AgentUpdate) { 194 if (nextPacket.Packet.Type != PacketType.AgentUpdate) {
195 packetsReceived++; 195 packetsReceived++;
196 } 196 }
197 ProcessInPacket(nextPacket.Packet); 197 ProcessInPacket(nextPacket.Packet);
198 } 198 }
199 else 199 else
200 { 200 {
201 //is a out going packet 201 //is a out going packet
202 ProcessOutPacket(nextPacket.Packet); 202 ProcessOutPacket(nextPacket.Packet);
203 } 203 }
204 } 204 }
205 } 205 }
206 # endregion 206 # endregion
207 207
208 protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) 208 protected void CheckClientConnectivity(object sender, ElapsedEventArgs e)
209 { 209 {
210 if (packetsReceived == lastPacketsReceived) { 210 if (packetsReceived == lastPacketsReceived) {
211 probesWithNoIngressPackets++; 211 probesWithNoIngressPackets++;
212 if (probesWithNoIngressPackets > 30) { 212 if (probesWithNoIngressPackets > 30) {
213 this.KillClient(); 213 this.KillClient();
214 } else { 214 } else {
215 // this will normally trigger at least one packet (ping response) 215 // this will normally trigger at least one packet (ping response)
216 SendStartPingCheck(0); 216 SendStartPingCheck(0);
217 } 217 }
218 } else { 218 } else {
219 // Something received in the meantime - we can reset the counters 219 // Something received in the meantime - we can reset the counters
220 probesWithNoIngressPackets = 0; 220 probesWithNoIngressPackets = 0;
221 lastPacketsReceived = packetsReceived; 221 lastPacketsReceived = packetsReceived;
222 } 222 }
223 } 223 }
224 224
225 # region Setup 225 # region Setup
226 226
227 protected virtual void InitNewClient() 227 protected virtual void InitNewClient()
228 { 228 {
229 clientPingTimer = new Timer(1000); 229 clientPingTimer = new Timer(1000);
230 clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); 230 clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
231 clientPingTimer.Enabled = true; 231 clientPingTimer.Enabled = true;
232 232
233 MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); 233 MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
234 this.m_world.AddNewClient(this, false); 234 this.m_world.AddNewClient(this, false);
235 } 235 }
236 236
237 protected virtual void AuthUser() 237 protected virtual void AuthUser()
238 { 238 {
239 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 239 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
240 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 240 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
241 if (!sessionInfo.Authorised) 241 if (!sessionInfo.Authorised)
242 { 242 {
243 //session/circuit not authorised 243 //session/circuit not authorised
244 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); 244 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
245 ClientThread.Abort(); 245 ClientThread.Abort();
246 } 246 }
247 else 247 else
248 { 248 {
249 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); 249 MainLog.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
250 //session is authorised 250 //session is authorised
251 this.AgentID = cirpack.CircuitCode.ID; 251 this.AgentID = cirpack.CircuitCode.ID;
252 this.SessionID = cirpack.CircuitCode.SessionID; 252 this.SessionID = cirpack.CircuitCode.SessionID;
253 this.CircuitCode = cirpack.CircuitCode.Code; 253 this.CircuitCode = cirpack.CircuitCode.Code;
254 this.firstName = sessionInfo.LoginInfo.First; 254 this.firstName = sessionInfo.LoginInfo.First;
255 this.lastName = sessionInfo.LoginInfo.Last; 255 this.lastName = sessionInfo.LoginInfo.Last;
256 256
257 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) 257 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
258 { 258 {
259 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; 259 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
260 } 260 }
261 InitNewClient(); 261 InitNewClient();
262 262
263 ClientLoop(); 263 ClientLoop();
264 } 264 }
265 } 265 }
266 # endregion 266 # endregion
267 267
268 268
269 protected override void KillThread() 269 protected override void KillThread()
270 { 270 {
271 this.ClientThread.Abort(); 271 this.ClientThread.Abort();
272 } 272 }
273 273
274 #region Inventory Creation 274 #region Inventory Creation
275 private void SetupInventory(AuthenticateResponse sessionInfo) 275 private void SetupInventory(AuthenticateResponse sessionInfo)
276 { 276 {
277 277
278 } 278 }
279 private AgentInventory CreateInventory(LLUUID baseFolder) 279 private AgentInventory CreateInventory(LLUUID baseFolder)
280 { 280 {
281 AgentInventory inventory = null; 281 AgentInventory inventory = null;
282 282
283 return inventory; 283 return inventory;
284 } 284 }
285 285
286 private void CreateInventoryItem(CreateInventoryItemPacket packet) 286 private void CreateInventoryItem(CreateInventoryItemPacket packet)
287 { 287 {
288 288
289 } 289 }
290 #endregion 290 #endregion
291 291
292 } 292 }
293} 293}
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
index cc04bda..597cd7d 100644
--- a/OpenSim/Region/ClientStack/ClientViewBase.cs
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -1,326 +1,326 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Net.Sockets; 31using System.Net.Sockets;
32using System.Timers; 32using System.Timers;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.Packets; 34using libsecondlife.Packets;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Region.Environment; 37using OpenSim.Region.Environment;
38 38
39namespace OpenSim.Region.ClientStack 39namespace OpenSim.Region.ClientStack
40{ 40{
41 public class ClientViewBase 41 public class ClientViewBase
42 { 42 {
43 protected BlockingQueue<QueItem> PacketQueue; 43 protected BlockingQueue<QueItem> PacketQueue;
44 protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); 44 protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
45 protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); 45 protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
46 46
47 protected Timer AckTimer; 47 protected Timer AckTimer;
48 protected uint Sequence = 0; 48 protected uint Sequence = 0;
49 protected object SequenceLock = new object(); 49 protected object SequenceLock = new object();
50 protected const int MAX_APPENDED_ACKS = 10; 50 protected const int MAX_APPENDED_ACKS = 10;
51 protected const int RESEND_TIMEOUT = 4000; 51 protected const int RESEND_TIMEOUT = 4000;
52 protected const int MAX_SEQUENCE = 0xFFFFFF; 52 protected const int MAX_SEQUENCE = 0xFFFFFF;
53 53
54 public uint CircuitCode; 54 public uint CircuitCode;
55 public EndPoint userEP; 55 public EndPoint userEP;
56 56
57 protected PacketServer m_networkServer; 57 protected PacketServer m_networkServer;
58 58
59 public ClientViewBase() 59 public ClientViewBase()
60 { 60 {
61 61
62 } 62 }
63 63
64 protected virtual void ProcessInPacket(Packet Pack) 64 protected virtual void ProcessInPacket(Packet Pack)
65 { 65 {
66 66
67 } 67 }
68 68
69 protected virtual void ProcessOutPacket(Packet Pack) 69 protected virtual void ProcessOutPacket(Packet Pack)
70 { 70 {
71 // Keep track of when this packet was sent out 71 // Keep track of when this packet was sent out
72 Pack.TickCount = System.Environment.TickCount; 72 Pack.TickCount = System.Environment.TickCount;
73 73
74 // Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString()); 74 // Console.WriteLine(CircuitCode + ":OUT: " + Pack.Type.ToString());
75 75
76 if (!Pack.Header.Resent) 76 if (!Pack.Header.Resent)
77 { 77 {
78 // Set the sequence number 78 // Set the sequence number
79 lock (SequenceLock) 79 lock (SequenceLock)
80 { 80 {
81 if (Sequence >= MAX_SEQUENCE) 81 if (Sequence >= MAX_SEQUENCE)
82 Sequence = 1; 82 Sequence = 1;
83 else 83 else
84 Sequence++; 84 Sequence++;
85 Pack.Header.Sequence = Sequence; 85 Pack.Header.Sequence = Sequence;
86 } 86 }
87 87
88 if (Pack.Header.Reliable) //DIRTY HACK 88 if (Pack.Header.Reliable) //DIRTY HACK
89 { 89 {
90 lock (NeedAck) 90 lock (NeedAck)
91 { 91 {
92 if (!NeedAck.ContainsKey(Pack.Header.Sequence)) 92 if (!NeedAck.ContainsKey(Pack.Header.Sequence))
93 { 93 {
94 try 94 try
95 { 95 {
96 NeedAck.Add(Pack.Header.Sequence, Pack); 96 NeedAck.Add(Pack.Header.Sequence, Pack);
97 } 97 }
98 catch (Exception e) // HACKY 98 catch (Exception e) // HACKY
99 { 99 {
100 e.ToString(); 100 e.ToString();
101 // Ignore 101 // Ignore
102 // Seems to throw a exception here occasionally 102 // Seems to throw a exception here occasionally
103 // of 'duplicate key' despite being locked. 103 // of 'duplicate key' despite being locked.
104 // !?!?!? 104 // !?!?!?
105 } 105 }
106 } 106 }
107 else 107 else
108 { 108 {
109 // Client.Log("Attempted to add a duplicate sequence number (" + 109 // Client.Log("Attempted to add a duplicate sequence number (" +
110 // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + 110 // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
111 // packet.Type.ToString(), Helpers.LogLevel.Warning); 111 // packet.Type.ToString(), Helpers.LogLevel.Warning);
112 } 112 }
113 } 113 }
114 114
115 // Don't append ACKs to resent packets, in case that's what was causing the 115 // Don't append ACKs to resent packets, in case that's what was causing the
116 // delivery to fail 116 // delivery to fail
117 if (!Pack.Header.Resent) 117 if (!Pack.Header.Resent)
118 { 118 {
119 // Append any ACKs that need to be sent out to this packet 119 // Append any ACKs that need to be sent out to this packet
120 lock (PendingAcks) 120 lock (PendingAcks)
121 { 121 {
122 if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && 122 if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
123 Pack.Type != PacketType.PacketAck && 123 Pack.Type != PacketType.PacketAck &&
124 Pack.Type != PacketType.LogoutRequest) 124 Pack.Type != PacketType.LogoutRequest)
125 { 125 {
126 Pack.Header.AckList = new uint[PendingAcks.Count]; 126 Pack.Header.AckList = new uint[PendingAcks.Count];
127 int i = 0; 127 int i = 0;
128 128
129 foreach (uint ack in PendingAcks.Values) 129 foreach (uint ack in PendingAcks.Values)
130 { 130 {
131 Pack.Header.AckList[i] = ack; 131 Pack.Header.AckList[i] = ack;
132 i++; 132 i++;
133 } 133 }
134 134
135 PendingAcks.Clear(); 135 PendingAcks.Clear();
136 Pack.Header.AppendedAcks = true; 136 Pack.Header.AppendedAcks = true;
137 } 137 }
138 } 138 }
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 byte[] ZeroOutBuffer = new byte[4096]; 143 byte[] ZeroOutBuffer = new byte[4096];
144 byte[] sendbuffer; 144 byte[] sendbuffer;
145 sendbuffer = Pack.ToBytes(); 145 sendbuffer = Pack.ToBytes();
146 146
147 try 147 try
148 { 148 {
149 if (Pack.Header.Zerocoded) 149 if (Pack.Header.Zerocoded)
150 { 150 {
151 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); 151 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
152 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); 152 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
153 } 153 }
154 else 154 else
155 { 155 {
156 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); 156 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
157 } 157 }
158 } 158 }
159 catch (Exception) 159 catch (Exception)
160 { 160 {
161 MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); 161 MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
162 this.KillThread(); 162 this.KillThread();
163 } 163 }
164 164
165 } 165 }
166 166
167 public virtual void InPacket(Packet NewPack) 167 public virtual void InPacket(Packet NewPack)
168 { 168 {
169 // Handle appended ACKs 169 // Handle appended ACKs
170 if (NewPack.Header.AppendedAcks) 170 if (NewPack.Header.AppendedAcks)
171 { 171 {
172 lock (NeedAck) 172 lock (NeedAck)
173 { 173 {
174 foreach (uint ack in NewPack.Header.AckList) 174 foreach (uint ack in NewPack.Header.AckList)
175 { 175 {
176 NeedAck.Remove(ack); 176 NeedAck.Remove(ack);
177 } 177 }
178 } 178 }
179 } 179 }
180 180
181 // Handle PacketAck packets 181 // Handle PacketAck packets
182 if (NewPack.Type == PacketType.PacketAck) 182 if (NewPack.Type == PacketType.PacketAck)
183 { 183 {
184 PacketAckPacket ackPacket = (PacketAckPacket)NewPack; 184 PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
185 185
186 lock (NeedAck) 186 lock (NeedAck)
187 { 187 {
188 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) 188 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
189 { 189 {
190 NeedAck.Remove(block.ID); 190 NeedAck.Remove(block.ID);
191 } 191 }
192 } 192 }
193 } 193 }
194 else if ((NewPack.Type == PacketType.StartPingCheck)) 194 else if ((NewPack.Type == PacketType.StartPingCheck))
195 { 195 {
196 //reply to pingcheck 196 //reply to pingcheck
197 StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; 197 StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack;
198 CompletePingCheckPacket endPing = new CompletePingCheckPacket(); 198 CompletePingCheckPacket endPing = new CompletePingCheckPacket();
199 endPing.PingID.PingID = startPing.PingID.PingID; 199 endPing.PingID.PingID = startPing.PingID.PingID;
200 OutPacket(endPing); 200 OutPacket(endPing);
201 } 201 }
202 else 202 else
203 { 203 {
204 QueItem item = new QueItem(); 204 QueItem item = new QueItem();
205 item.Packet = NewPack; 205 item.Packet = NewPack;
206 item.Incoming = true; 206 item.Incoming = true;
207 this.PacketQueue.Enqueue(item); 207 this.PacketQueue.Enqueue(item);
208 } 208 }
209 209
210 } 210 }
211 211
212 public virtual void OutPacket(Packet NewPack) 212 public virtual void OutPacket(Packet NewPack)
213 { 213 {
214 QueItem item = new QueItem(); 214 QueItem item = new QueItem();
215 item.Packet = NewPack; 215 item.Packet = NewPack;
216 item.Incoming = false; 216 item.Incoming = false;
217 this.PacketQueue.Enqueue(item); 217 this.PacketQueue.Enqueue(item);
218 } 218 }
219 219
220 # region Low Level Packet Methods 220 # region Low Level Packet Methods
221 221
222 protected void ack_pack(Packet Pack) 222 protected void ack_pack(Packet Pack)
223 { 223 {
224 if (Pack.Header.Reliable) 224 if (Pack.Header.Reliable)
225 { 225 {
226 PacketAckPacket ack_it = new PacketAckPacket(); 226 PacketAckPacket ack_it = new PacketAckPacket();
227 ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; 227 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
228 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); 228 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
229 ack_it.Packets[0].ID = Pack.Header.Sequence; 229 ack_it.Packets[0].ID = Pack.Header.Sequence;
230 ack_it.Header.Reliable = false; 230 ack_it.Header.Reliable = false;
231 231
232 OutPacket(ack_it); 232 OutPacket(ack_it);
233 233
234 } 234 }
235 /* 235 /*
236 if (Pack.Header.Reliable) 236 if (Pack.Header.Reliable)
237 { 237 {
238 lock (PendingAcks) 238 lock (PendingAcks)
239 { 239 {
240 uint sequence = (uint)Pack.Header.Sequence; 240 uint sequence = (uint)Pack.Header.Sequence;
241 if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } 241 if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
242 } 242 }
243 }*/ 243 }*/
244 } 244 }
245 245
246 protected void ResendUnacked() 246 protected void ResendUnacked()
247 { 247 {
248 int now = System.Environment.TickCount; 248 int now = System.Environment.TickCount;
249 249
250 lock (NeedAck) 250 lock (NeedAck)
251 { 251 {
252 foreach (Packet packet in NeedAck.Values) 252 foreach (Packet packet in NeedAck.Values)
253 { 253 {
254 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) 254 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
255 { 255 {
256 MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " + 256 MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " +
257 (now - packet.TickCount) + "ms have passed"); 257 (now - packet.TickCount) + "ms have passed");
258 258
259 packet.Header.Resent = true; 259 packet.Header.Resent = true;
260 OutPacket(packet); 260 OutPacket(packet);
261 } 261 }
262 } 262 }
263 } 263 }
264 } 264 }
265 265
266 protected void SendAcks() 266 protected void SendAcks()
267 { 267 {
268 lock (PendingAcks) 268 lock (PendingAcks)
269 { 269 {
270 if (PendingAcks.Count > 0) 270 if (PendingAcks.Count > 0)
271 { 271 {
272 if (PendingAcks.Count > 250) 272 if (PendingAcks.Count > 250)
273 { 273 {
274 // FIXME: Handle the odd case where we have too many pending ACKs queued up 274 // FIXME: Handle the odd case where we have too many pending ACKs queued up
275 MainLog.Instance.Verbose( "Too many ACKs queued up!"); 275 MainLog.Instance.Verbose( "Too many ACKs queued up!");
276 return; 276 return;
277 } 277 }
278 278
279 //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck"); 279 //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck");
280 280
281 281
282 int i = 0; 282 int i = 0;
283 PacketAckPacket acks = new PacketAckPacket(); 283 PacketAckPacket acks = new PacketAckPacket();
284 acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; 284 acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
285 285
286 foreach (uint ack in PendingAcks.Values) 286 foreach (uint ack in PendingAcks.Values)
287 { 287 {
288 acks.Packets[i] = new PacketAckPacket.PacketsBlock(); 288 acks.Packets[i] = new PacketAckPacket.PacketsBlock();
289 acks.Packets[i].ID = ack; 289 acks.Packets[i].ID = ack;
290 i++; 290 i++;
291 } 291 }
292 292
293 acks.Header.Reliable = false; 293 acks.Header.Reliable = false;
294 OutPacket(acks); 294 OutPacket(acks);
295 295
296 PendingAcks.Clear(); 296 PendingAcks.Clear();
297 } 297 }
298 } 298 }
299 } 299 }
300 300
301 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) 301 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
302 { 302 {
303 SendAcks(); 303 SendAcks();
304 ResendUnacked(); 304 ResendUnacked();
305 } 305 }
306 #endregion 306 #endregion
307 307
308 protected virtual void KillThread() 308 protected virtual void KillThread()
309 { 309 {
310 310
311 } 311 }
312 312
313 #region Nested Classes 313 #region Nested Classes
314 314
315 public class QueItem 315 public class QueItem
316 { 316 {
317 public QueItem() 317 public QueItem()
318 { 318 {
319 } 319 }
320 320
321 public Packet Packet; 321 public Packet Packet;
322 public bool Incoming; 322 public bool Incoming;
323 } 323 }
324 #endregion 324 #endregion
325 } 325 }
326} 326}
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index a88c682..466fdde 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -1,184 +1,184 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Net; 29using System.Net;
30using System.Net.Sockets; 30using System.Net.Sockets;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Assets; 32using OpenSim.Assets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Region.Caches; 35using OpenSim.Region.Caches;
36 36
37namespace OpenSim.Region.ClientStack 37namespace OpenSim.Region.ClientStack
38{ 38{
39 public class PacketServer 39 public class PacketServer
40 { 40 {
41 private ClientStackNetworkHandler _networkHandler; 41 private ClientStackNetworkHandler _networkHandler;
42 private IWorld _localWorld; 42 private IWorld _localWorld;
43 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); 43 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
44 private ClientManager m_clientManager = new ClientManager(); 44 private ClientManager m_clientManager = new ClientManager();
45 public ClientManager ClientManager 45 public ClientManager ClientManager
46 { 46 {
47 get { return m_clientManager; } 47 get { return m_clientManager; }
48 } 48 }
49 49
50 public PacketServer(ClientStackNetworkHandler networkHandler) 50 public PacketServer(ClientStackNetworkHandler networkHandler)
51 { 51 {
52 _networkHandler = networkHandler; 52 _networkHandler = networkHandler;
53 _networkHandler.RegisterPacketServer(this); 53 _networkHandler.RegisterPacketServer(this);
54 } 54 }
55 55
56 public IWorld LocalWorld 56 public IWorld LocalWorld
57 { 57 {
58 set 58 set
59 { 59 {
60 this._localWorld = value; 60 this._localWorld = value;
61 } 61 }
62 } 62 }
63 63
64 /// <summary> 64 /// <summary>
65 /// 65 ///
66 /// </summary> 66 /// </summary>
67 /// <param name="circuitCode"></param> 67 /// <param name="circuitCode"></param>
68 /// <param name="packet"></param> 68 /// <param name="packet"></param>
69 public virtual void ClientInPacket(uint circuitCode, Packet packet) 69 public virtual void ClientInPacket(uint circuitCode, Packet packet)
70 { 70 {
71 if (this.ClientThreads.ContainsKey(circuitCode)) 71 if (this.ClientThreads.ContainsKey(circuitCode))
72 { 72 {
73 ClientThreads[circuitCode].InPacket(packet); 73 ClientThreads[circuitCode].InPacket(packet);
74 } 74 }
75 } 75 }
76 76
77 /// <summary> 77 /// <summary>
78 /// 78 ///
79 /// </summary> 79 /// </summary>
80 /// <param name="circuitCode"></param> 80 /// <param name="circuitCode"></param>
81 /// <returns></returns> 81 /// <returns></returns>
82 public virtual bool AddNewCircuitCodeClient(uint circuitCode) 82 public virtual bool AddNewCircuitCodeClient(uint circuitCode)
83 { 83 {
84 return false; 84 return false;
85 } 85 }
86 86
87 /// <summary> 87 /// <summary>
88 /// 88 ///
89 /// </summary> 89 /// </summary>
90 /// <param name="packet"></param> 90 /// <param name="packet"></param>
91 public virtual void SendPacketToAllClients(Packet packet) 91 public virtual void SendPacketToAllClients(Packet packet)
92 { 92 {
93 93
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
97 /// 97 ///
98 /// </summary> 98 /// </summary>
99 /// <param name="packet"></param> 99 /// <param name="packet"></param>
100 /// <param name="simClient"></param> 100 /// <param name="simClient"></param>
101 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) 101 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
102 { 102 {
103 103
104 } 104 }
105 105
106 /// <summary> 106 /// <summary>
107 /// 107 ///
108 /// </summary> 108 /// </summary>
109 /// <param name="packetType"></param> 109 /// <param name="packetType"></param>
110 /// <param name="handler"></param> 110 /// <param name="handler"></param>
111 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) 111 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
112 { 112 {
113 113
114 } 114 }
115 115
116 /// <summary> 116 /// <summary>
117 /// 117 ///
118 /// </summary> 118 /// </summary>
119 public virtual void RegisterClientPacketHandlers() 119 public virtual void RegisterClientPacketHandlers()
120 { 120 {
121 121
122 } 122 }
123 123
124 /// <summary> 124 /// <summary>
125 /// 125 ///
126 /// </summary> 126 /// </summary>
127 /// <param name="remoteEP"></param> 127 /// <param name="remoteEP"></param>
128 /// <param name="initialcirpack"></param> 128 /// <param name="initialcirpack"></param>
129 /// <param name="clientThreads"></param> 129 /// <param name="clientThreads"></param>
130 /// <param name="world"></param> 130 /// <param name="world"></param>
131 /// <param name="assetCache"></param> 131 /// <param name="assetCache"></param>
132 /// <param name="packServer"></param> 132 /// <param name="packServer"></param>
133 /// <param name="inventoryCache"></param> 133 /// <param name="inventoryCache"></param>
134 /// <param name="authenSessions"></param> 134 /// <param name="authenSessions"></param>
135 /// <returns></returns> 135 /// <returns></returns>
136 protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) 136 protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
137 { 137 {
138 return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); 138 return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions );
139 } 139 }
140 140
141 /// <summary> 141 /// <summary>
142 /// 142 ///
143 /// </summary> 143 /// </summary>
144 /// <param name="epSender"></param> 144 /// <param name="epSender"></param>
145 /// <param name="useCircuit"></param> 145 /// <param name="useCircuit"></param>
146 /// <param name="assetCache"></param> 146 /// <param name="assetCache"></param>
147 /// <param name="inventoryCache"></param> 147 /// <param name="inventoryCache"></param>
148 /// <param name="authenticateSessionsClass"></param> 148 /// <param name="authenticateSessionsClass"></param>
149 /// <returns></returns> 149 /// <returns></returns>
150 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) 150 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
151 { 151 {
152 ClientView newuser = 152 ClientView newuser =
153 CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache, 153 CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache,
154 authenticateSessionsClass); 154 authenticateSessionsClass);
155 155
156 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); 156 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
157 this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser); 157 this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);
158 158
159 return true; 159 return true;
160 } 160 }
161 161
162 /// <summary> 162 /// <summary>
163 /// 163 ///
164 /// </summary> 164 /// </summary>
165 /// <param name="buffer"></param> 165 /// <param name="buffer"></param>
166 /// <param name="size"></param> 166 /// <param name="size"></param>
167 /// <param name="flags"></param> 167 /// <param name="flags"></param>
168 /// <param name="circuitcode"></param> 168 /// <param name="circuitcode"></param>
169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) 169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
170 { 170 {
171 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); 171 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
172 } 172 }
173 173
174 /// <summary> 174 /// <summary>
175 /// 175 ///
176 /// </summary> 176 /// </summary>
177 /// <param name="circuitcode"></param> 177 /// <param name="circuitcode"></param>
178 public virtual void RemoveClientCircuit(uint circuitcode) 178 public virtual void RemoveClientCircuit(uint circuitcode)
179 { 179 {
180 this._networkHandler.RemoveClientCircuit(circuitcode); 180 this._networkHandler.RemoveClientCircuit(circuitcode);
181 this.m_clientManager.Remove(circuitcode); 181 this.m_clientManager.Remove(circuitcode);
182 } 182 }
183 } 183 }
184} 184}
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 7ae74f8..ed7df17 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -1,118 +1,118 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using OpenSim.Assets; 31using OpenSim.Assets;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Physics.Manager; 37using OpenSim.Physics.Manager;
38using OpenSim.Region.Caches; 38using OpenSim.Region.Caches;
39using OpenSim.Region.Environment; 39using OpenSim.Region.Environment;
40 40
41namespace OpenSim.Region.ClientStack 41namespace OpenSim.Region.ClientStack
42{ 42{
43 public class RegionApplicationBase 43 public class RegionApplicationBase
44 { 44 {
45 protected IGenericConfig localConfig; 45 protected IGenericConfig localConfig;
46 protected PhysicsManager physManager; 46 protected PhysicsManager physManager;
47 protected AssetCache AssetCache; 47 protected AssetCache AssetCache;
48 protected InventoryCache InventoryCache; 48 protected InventoryCache InventoryCache;
49 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 49 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
50 protected DateTime startuptime; 50 protected DateTime startuptime;
51 protected NetworkServersInfo serversData; 51 protected NetworkServersInfo serversData;
52 52
53 public string m_physicsEngine; 53 public string m_physicsEngine;
54 public bool m_sandbox = false; 54 public bool m_sandbox = false;
55 public bool m_loginserver; 55 public bool m_loginserver;
56 public bool user_accounts = false; 56 public bool user_accounts = false;
57 public bool gridLocalAsset = false; 57 public bool gridLocalAsset = false;
58 protected bool configFileSetup = false; 58 protected bool configFileSetup = false;
59 public string m_config; 59 public string m_config;
60 60
61 protected List<UDPServer> m_udpServer = new List<UDPServer>(); 61 protected List<UDPServer> m_udpServer = new List<UDPServer>();
62 protected List<RegionInfo> regionData = new List<RegionInfo>(); 62 protected List<RegionInfo> regionData = new List<RegionInfo>();
63 protected List<IWorld> m_localWorld = new List<IWorld>(); 63 protected List<IWorld> m_localWorld = new List<IWorld>();
64 protected BaseHttpServer httpServer; 64 protected BaseHttpServer httpServer;
65 protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>(); 65 protected List<AuthenticateSessionsBase> AuthenticateSessionsHandler = new List<AuthenticateSessionsBase>();
66 66
67 protected LogBase m_log; 67 protected LogBase m_log;
68 68
69 public RegionApplicationBase() 69 public RegionApplicationBase()
70 { 70 {
71 71
72 } 72 }
73 73
74 public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) 74 public RegionApplicationBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
75 { 75 {
76 this.configFileSetup = useConfigFile; 76 this.configFileSetup = useConfigFile;
77 m_sandbox = sandBoxMode; 77 m_sandbox = sandBoxMode;
78 m_loginserver = startLoginServer; 78 m_loginserver = startLoginServer;
79 m_physicsEngine = physicsEngine; 79 m_physicsEngine = physicsEngine;
80 m_config = configFile; 80 m_config = configFile;
81 } 81 }
82 82
83 /*protected World m_localWorld; 83 /*protected World m_localWorld;
84 public World LocalWorld 84 public World LocalWorld
85 { 85 {
86 get { return m_localWorld; } 86 get { return m_localWorld; }
87 }*/ 87 }*/
88 88
89 /// <summary> 89 /// <summary>
90 /// Performs initialisation of the world, such as loading configuration from disk. 90 /// Performs initialisation of the world, such as loading configuration from disk.
91 /// </summary> 91 /// </summary>
92 public virtual void StartUp() 92 public virtual void StartUp()
93 { 93 {
94 } 94 }
95 95
96 protected virtual void SetupLocalGridServers() 96 protected virtual void SetupLocalGridServers()
97 { 97 {
98 } 98 }
99 99
100 protected virtual void SetupRemoteGridServers() 100 protected virtual void SetupRemoteGridServers()
101 { 101 {
102 102
103 } 103 }
104 104
105 protected virtual void SetupScene() 105 protected virtual void SetupScene()
106 { 106 {
107 } 107 }
108 108
109 protected virtual void SetupHttpListener() 109 protected virtual void SetupHttpListener()
110 { 110 {
111 } 111 }
112 112
113 protected virtual void ConnectToRemoteGridServer() 113 protected virtual void ConnectToRemoteGridServer()
114 { 114 {
115 115
116 } 116 }
117 } 117 }
118} 118}
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 6eea524..781f96a 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -1,196 +1,196 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Net.Sockets; 31using System.Net.Sockets;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Assets; 33using OpenSim.Assets;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Region.Caches; 37using OpenSim.Region.Caches;
38 38
39namespace OpenSim.Region.ClientStack 39namespace OpenSim.Region.ClientStack
40{ 40{
41 41
42 public class UDPServer : ClientStackNetworkHandler 42 public class UDPServer : ClientStackNetworkHandler
43 { 43 {
44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
45 public Socket Server; 45 public Socket Server;
46 protected IPEndPoint ServerIncoming; 46 protected IPEndPoint ServerIncoming;
47 protected byte[] RecvBuffer = new byte[4096]; 47 protected byte[] RecvBuffer = new byte[4096];
48 protected byte[] ZeroBuffer = new byte[8192]; 48 protected byte[] ZeroBuffer = new byte[8192];
49 protected IPEndPoint ipeSender; 49 protected IPEndPoint ipeSender;
50 protected EndPoint epSender; 50 protected EndPoint epSender;
51 protected AsyncCallback ReceivedData; 51 protected AsyncCallback ReceivedData;
52 protected PacketServer _packetServer; 52 protected PacketServer _packetServer;
53 53
54 protected int listenPort; 54 protected int listenPort;
55 protected IWorld m_localWorld; 55 protected IWorld m_localWorld;
56 protected AssetCache m_assetCache; 56 protected AssetCache m_assetCache;
57 protected InventoryCache m_inventoryCache; 57 protected InventoryCache m_inventoryCache;
58 protected LogBase m_log; 58 protected LogBase m_log;
59 protected AuthenticateSessionsBase m_authenticateSessionsClass; 59 protected AuthenticateSessionsBase m_authenticateSessionsClass;
60 60
61 public PacketServer PacketServer 61 public PacketServer PacketServer
62 { 62 {
63 get 63 get
64 { 64 {
65 return _packetServer; 65 return _packetServer;
66 } 66 }
67 set 67 set
68 { 68 {
69 _packetServer = value; 69 _packetServer = value;
70 } 70 }
71 } 71 }
72 72
73 public IWorld LocalWorld 73 public IWorld LocalWorld
74 { 74 {
75 set 75 set
76 { 76 {
77 this.m_localWorld = value; 77 this.m_localWorld = value;
78 this._packetServer.LocalWorld = this.m_localWorld; 78 this._packetServer.LocalWorld = this.m_localWorld;
79 } 79 }
80 } 80 }
81 81
82 public UDPServer() 82 public UDPServer()
83 { 83 {
84 } 84 }
85 85
86 public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass) 86 public UDPServer(int port, AssetCache assetCache, InventoryCache inventoryCache, LogBase console, AuthenticateSessionsBase authenticateClass)
87 { 87 {
88 listenPort = port; 88 listenPort = port;
89 this.m_assetCache = assetCache; 89 this.m_assetCache = assetCache;
90 this.m_inventoryCache = inventoryCache; 90 this.m_inventoryCache = inventoryCache;
91 this.m_log = console; 91 this.m_log = console;
92 this.m_authenticateSessionsClass = authenticateClass; 92 this.m_authenticateSessionsClass = authenticateClass;
93 this.CreatePacketServer(); 93 this.CreatePacketServer();
94 94
95 } 95 }
96 96
97 protected virtual void CreatePacketServer() 97 protected virtual void CreatePacketServer()
98 { 98 {
99 PacketServer packetServer = new PacketServer(this); 99 PacketServer packetServer = new PacketServer(this);
100 } 100 }
101 101
102 protected virtual void OnReceivedData(IAsyncResult result) 102 protected virtual void OnReceivedData(IAsyncResult result)
103 { 103 {
104 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 104 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
105 epSender = (EndPoint)ipeSender; 105 epSender = (EndPoint)ipeSender;
106 Packet packet = null; 106 Packet packet = null;
107 int numBytes = Server.EndReceiveFrom(result, ref epSender); 107 int numBytes = Server.EndReceiveFrom(result, ref epSender);
108 int packetEnd = numBytes - 1; 108 int packetEnd = numBytes - 1;
109 109
110 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 110 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
111 111
112 // do we already have a circuit for this endpoint 112 // do we already have a circuit for this endpoint
113 if (this.clientCircuits.ContainsKey(epSender)) 113 if (this.clientCircuits.ContainsKey(epSender))
114 { 114 {
115 //if so then send packet to the packetserver 115 //if so then send packet to the packetserver
116 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet); 116 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
117 } 117 }
118 else if (packet.Type == PacketType.UseCircuitCode) 118 else if (packet.Type == PacketType.UseCircuitCode)
119 { 119 {
120 // new client 120 // new client
121 this.AddNewClient(packet); 121 this.AddNewClient(packet);
122 } 122 }
123 else 123 else
124 { // invalid client 124 { // invalid client
125 m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); 125 m_log.Warn("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
126 } 126 }
127 127
128 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 128 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
129 } 129 }
130 130
131 protected virtual void AddNewClient(Packet packet) 131 protected virtual void AddNewClient(Packet packet)
132 { 132 {
133 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; 133 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
134 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 134 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
135 135
136 this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass); 136 this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_inventoryCache, m_authenticateSessionsClass);
137 } 137 }
138 138
139 public void ServerListener() 139 public void ServerListener()
140 { 140 {
141 m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort); 141 m_log.Status("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort);
142 142
143 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); 143 ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort);
144 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 144 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
145 Server.Bind(ServerIncoming); 145 Server.Bind(ServerIncoming);
146 146
147 m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen"); 147 m_log.Verbose("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
148 148
149 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 149 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
150 epSender = (EndPoint)ipeSender; 150 epSender = (EndPoint)ipeSender;
151 ReceivedData = new AsyncCallback(this.OnReceivedData); 151 ReceivedData = new AsyncCallback(this.OnReceivedData);
152 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 152 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
153 153
154 m_log.Verbose("UDPServer.cs:ServerListener() - Listening..."); 154 m_log.Verbose("UDPServer.cs:ServerListener() - Listening...");
155 155
156 } 156 }
157 157
158 public virtual void RegisterPacketServer(PacketServer server) 158 public virtual void RegisterPacketServer(PacketServer server)
159 { 159 {
160 this._packetServer = server; 160 this._packetServer = server;
161 } 161 }
162 162
163 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) 163 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
164 { 164 {
165 // find the endpoint for this circuit 165 // find the endpoint for this circuit
166 EndPoint sendto = null; 166 EndPoint sendto = null;
167 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) 167 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
168 { 168 {
169 if (p.Value == circuitcode) 169 if (p.Value == circuitcode)
170 { 170 {
171 sendto = p.Key; 171 sendto = p.Key;
172 break; 172 break;
173 } 173 }
174 } 174 }
175 if (sendto != null) 175 if (sendto != null)
176 { 176 {
177 //we found the endpoint so send the packet to it 177 //we found the endpoint so send the packet to it
178 this.Server.SendTo(buffer, size, flags, sendto); 178 this.Server.SendTo(buffer, size, flags, sendto);
179 } 179 }
180 } 180 }
181 181
182 public virtual void RemoveClientCircuit(uint circuitcode) 182 public virtual void RemoveClientCircuit(uint circuitcode)
183 { 183 {
184 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) 184 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
185 { 185 {
186 if (p.Value == circuitcode) 186 if (p.Value == circuitcode)
187 { 187 {
188 this.clientCircuits.Remove(p.Key); 188 this.clientCircuits.Remove(p.Key);
189 break; 189 break;
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 194
195 } 195 }
196} \ No newline at end of file 196} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
index c47904d..3ce0cc5 100644
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -1,55 +1,55 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using OpenSim.Framework.Communications; 28using OpenSim.Framework.Communications;
29using OpenSim.Framework.Types; 29using OpenSim.Framework.Types;
30using OpenSim.Framework.Servers; 30using OpenSim.Framework.Servers;
31 31
32namespace OpenSim.Region.Communications.Local 32namespace OpenSim.Region.Communications.Local
33{ 33{
34 public class CommunicationsLocal : CommunicationsManager 34 public class CommunicationsLocal : CommunicationsManager
35 { 35 {
36 public LocalBackEndServices SandBoxServices = new LocalBackEndServices(); 36 public LocalBackEndServices SandBoxServices = new LocalBackEndServices();
37 public LocalUserServices UserServices; 37 public LocalUserServices UserServices;
38 38
39 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) 39 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer )
40 : base(serversInfo, httpServer) 40 : base(serversInfo, httpServer)
41 { 41 {
42 UserServices = new LocalUserServices(this, serversInfo); 42 UserServices = new LocalUserServices(this, serversInfo);
43 UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); 43 UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll");
44 UserServer = UserServices; 44 UserServer = UserServices;
45 GridServer = SandBoxServices; 45 GridServer = SandBoxServices;
46 InterRegion = SandBoxServices; 46 InterRegion = SandBoxServices;
47 httpServer.AddXmlRPCHandler("login_to_simulator", UserServices.XmlRpcLoginMethod); 47 httpServer.AddXmlRPCHandler("login_to_simulator", UserServices.XmlRpcLoginMethod);
48 } 48 }
49 49
50 internal void InformRegionOfLogin(ulong regionHandle, Login login) 50 internal void InformRegionOfLogin(ulong regionHandle, Login login)
51 { 51 {
52 this.SandBoxServices.AddNewSession(regionHandle, login); 52 this.SandBoxServices.AddNewSession(regionHandle, login);
53 } 53 }
54 } 54 }
55} 55}
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
index d0cd991..9322f3b 100644
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -1,206 +1,206 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Framework.Communications; 31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Types; 32using OpenSim.Framework.Types;
33 33
34namespace OpenSim.Region.Communications.Local 34namespace OpenSim.Region.Communications.Local
35{ 35{
36 36
37 public class LocalBackEndServices : IGridServices, IInterRegionCommunications 37 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
38 { 38 {
39 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); 39 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
40 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>(); 40 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
41 41
42 public LocalBackEndServices() 42 public LocalBackEndServices()
43 { 43 {
44 44
45 } 45 }
46 46
47 /// <summary> 47 /// <summary>
48 /// Register a region method with the BackEnd Services. 48 /// Register a region method with the BackEnd Services.
49 /// </summary> 49 /// </summary>
50 /// <param name="regionInfo"></param> 50 /// <param name="regionInfo"></param>
51 /// <returns></returns> 51 /// <returns></returns>
52 public RegionCommsListener RegisterRegion(RegionInfo regionInfo) 52 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
53 { 53 {
54 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); 54 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
55 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) 55 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
56 { 56 {
57 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle ); 57 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
58 this.regions.Add(regionInfo.RegionHandle, regionInfo); 58 this.regions.Add(regionInfo.RegionHandle, regionInfo);
59 RegionCommsListener regionHost = new RegionCommsListener(); 59 RegionCommsListener regionHost = new RegionCommsListener();
60 this.regionHosts.Add(regionInfo.RegionHandle, regionHost); 60 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
61 61
62 return regionHost; 62 return regionHost;
63 } 63 }
64 64
65 //already in our list of regions so for now lets return null 65 //already in our list of regions so for now lets return null
66 return null; 66 return null;
67 } 67 }
68 68
69 /// <summary> 69 /// <summary>
70 /// </summary> 70 /// </summary>
71 /// <param name="regionInfo"></param> 71 /// <param name="regionInfo"></param>
72 /// <returns></returns> 72 /// <returns></returns>
73 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) 73 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
74 { 74 {
75 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle); 75 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
76 List<RegionInfo> neighbours = new List<RegionInfo>(); 76 List<RegionInfo> neighbours = new List<RegionInfo>();
77 77
78 foreach (RegionInfo reg in this.regions.Values) 78 foreach (RegionInfo reg in this.regions.Values)
79 { 79 {
80 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY); 80 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
81 if (reg.RegionHandle != regionInfo.RegionHandle) 81 if (reg.RegionHandle != regionInfo.RegionHandle)
82 { 82 {
83 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location"); 83 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
84 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2))) 84 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
85 { 85 {
86 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2))) 86 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
87 { 87 {
88 neighbours.Add(reg); 88 neighbours.Add(reg);
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93 return neighbours; 93 return neighbours;
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
97 /// 97 ///
98 /// </summary> 98 /// </summary>
99 /// <param name="regionHandle"></param> 99 /// <param name="regionHandle"></param>
100 /// <returns></returns> 100 /// <returns></returns>
101 public RegionInfo RequestNeighbourInfo(ulong regionHandle) 101 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
102 { 102 {
103 if (this.regions.ContainsKey(regionHandle)) 103 if (this.regions.ContainsKey(regionHandle))
104 { 104 {
105 return this.regions[regionHandle]; 105 return this.regions[regionHandle];
106 } 106 }
107 return null; 107 return null;
108 } 108 }
109 109
110 /// <summary> 110 /// <summary>
111 /// 111 ///
112 /// </summary> 112 /// </summary>
113 /// <param name="minX"></param> 113 /// <param name="minX"></param>
114 /// <param name="minY"></param> 114 /// <param name="minY"></param>
115 /// <param name="maxX"></param> 115 /// <param name="maxX"></param>
116 /// <param name="maxY"></param> 116 /// <param name="maxY"></param>
117 /// <returns></returns> 117 /// <returns></returns>
118 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) 118 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
119 { 119 {
120 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 120 List<MapBlockData> mapBlocks = new List<MapBlockData>();
121 foreach(RegionInfo regInfo in this.regions.Values) 121 foreach(RegionInfo regInfo in this.regions.Values)
122 { 122 {
123 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) 123 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
124 { 124 {
125 MapBlockData map = new MapBlockData(); 125 MapBlockData map = new MapBlockData();
126 map.Name = regInfo.RegionName; 126 map.Name = regInfo.RegionName;
127 map.X = (ushort)regInfo.RegionLocX; 127 map.X = (ushort)regInfo.RegionLocX;
128 map.Y = (ushort)regInfo.RegionLocY; 128 map.Y = (ushort)regInfo.RegionLocY;
129 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight; 129 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight;
130 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007"); 130 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007");
131 map.Agents = 1; 131 map.Agents = 1;
132 map.RegionFlags = 72458694; 132 map.RegionFlags = 72458694;
133 map.Access = 13; 133 map.Access = 13;
134 mapBlocks.Add(map); 134 mapBlocks.Add(map);
135 } 135 }
136 } 136 }
137 return mapBlocks; 137 return mapBlocks;
138 } 138 }
139 139
140 /// <summary> 140 /// <summary>
141 /// </summary> 141 /// </summary>
142 /// <param name="regionHandle"></param> 142 /// <param name="regionHandle"></param>
143 /// <param name="agentData"></param> 143 /// <param name="agentData"></param>
144 /// <returns></returns> 144 /// <returns></returns>
145 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData 145 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
146 { 146 {
147 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); 147 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
148 if (this.regionHosts.ContainsKey(regionHandle)) 148 if (this.regionHosts.ContainsKey(regionHandle))
149 { 149 {
150 // Console.WriteLine("CommsManager- Informing a region to expect child agent"); 150 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
151 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData); 151 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
152 return true; 152 return true;
153 } 153 }
154 return false; 154 return false;
155 } 155 }
156 156
157 /// <summary> 157 /// <summary>
158 /// 158 ///
159 /// </summary> 159 /// </summary>
160 /// <param name="regionHandle"></param> 160 /// <param name="regionHandle"></param>
161 /// <param name="agentID"></param> 161 /// <param name="agentID"></param>
162 /// <param name="position"></param> 162 /// <param name="position"></param>
163 /// <returns></returns> 163 /// <returns></returns>
164 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 164 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
165 { 165 {
166 if (this.regionHosts.ContainsKey(regionHandle)) 166 if (this.regionHosts.ContainsKey(regionHandle))
167 { 167 {
168 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing"); 168 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
169 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); 169 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
170 return true; 170 return true;
171 } 171 }
172 return false; 172 return false;
173 } 173 }
174 174
175 /// <summary> 175 /// <summary>
176 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session 176 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
177 /// </summary> 177 /// </summary>
178 /// <param name="regionHandle"></param> 178 /// <param name="regionHandle"></param>
179 /// <param name="loginData"></param> 179 /// <param name="loginData"></param>
180 /// <returns></returns> 180 /// <returns></returns>
181 public bool AddNewSession(ulong regionHandle, Login loginData) 181 public bool AddNewSession(ulong regionHandle, Login loginData)
182 { 182 {
183 AgentCircuitData agent = new AgentCircuitData(); 183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = loginData.Agent; 184 agent.AgentID = loginData.Agent;
185 agent.firstname = loginData.First; 185 agent.firstname = loginData.First;
186 agent.lastname = loginData.Last; 186 agent.lastname = loginData.Last;
187 agent.SessionID = loginData.Session; 187 agent.SessionID = loginData.Session;
188 agent.SecureSessionID = loginData.SecureSession; 188 agent.SecureSessionID = loginData.SecureSession;
189 agent.circuitcode = loginData.CircuitCode; 189 agent.circuitcode = loginData.CircuitCode;
190 agent.BaseFolder = loginData.BaseFolder; 190 agent.BaseFolder = loginData.BaseFolder;
191 agent.InventoryFolder = loginData.InventoryFolder; 191 agent.InventoryFolder = loginData.InventoryFolder;
192 agent.startpos = new LLVector3(128, 128, 70); 192 agent.startpos = new LLVector3(128, 128, 70);
193 agent.CapsPath = loginData.CapsPath; 193 agent.CapsPath = loginData.CapsPath;
194 194
195 if (this.regionHosts.ContainsKey(regionHandle)) 195 if (this.regionHosts.ContainsKey(regionHandle))
196 { 196 {
197 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); 197 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
198 return true; 198 return true;
199 } 199 }
200 200
201 // region not found 201 // region not found
202 return false; 202 return false;
203 } 203 }
204 } 204 }
205} 205}
206 206
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
index 592b36c..a4cefc4 100644
--- a/OpenSim/Region/Communications/Local/LocalUserServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -1,142 +1,142 @@
1using System; 1using System;
2using libsecondlife; 2using libsecondlife;
3using OpenSim.Framework.Communications; 3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Data; 4using OpenSim.Framework.Data;
5using OpenSim.Framework.Types; 5using OpenSim.Framework.Types;
6using OpenSim.Framework.UserManagement; 6using OpenSim.Framework.UserManagement;
7using OpenSim.Framework.Utilities; 7using OpenSim.Framework.Utilities;
8 8
9namespace OpenSim.Region.Communications.Local 9namespace OpenSim.Region.Communications.Local
10{ 10{
11 public class LocalUserServices : UserManagerBase, IUserServices 11 public class LocalUserServices : UserManagerBase, IUserServices
12 { 12 {
13 private CommunicationsLocal m_Parent; 13 private CommunicationsLocal m_Parent;
14 14
15 private NetworkServersInfo serversInfo; 15 private NetworkServersInfo serversInfo;
16 private uint defaultHomeX ; 16 private uint defaultHomeX ;
17 private uint defaultHomeY; 17 private uint defaultHomeY;
18 public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData) 18 public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
19 { 19 {
20 m_Parent = parent; 20 m_Parent = parent;
21 this.serversInfo = serversData; 21 this.serversInfo = serversData;
22 defaultHomeX = this.serversInfo.DefaultHomeLocX; 22 defaultHomeX = this.serversInfo.DefaultHomeLocX;
23 defaultHomeY = this.serversInfo.DefaultHomeLocY; 23 defaultHomeY = this.serversInfo.DefaultHomeLocY;
24 } 24 }
25 25
26 public UserProfileData GetUserProfile(string firstName, string lastName) 26 public UserProfileData GetUserProfile(string firstName, string lastName)
27 { 27 {
28 return GetUserProfile(firstName + " " + lastName); 28 return GetUserProfile(firstName + " " + lastName);
29 } 29 }
30 30
31 public UserProfileData GetUserProfile(string name) 31 public UserProfileData GetUserProfile(string name)
32 { 32 {
33 return this.getUserProfile(name); 33 return this.getUserProfile(name);
34 } 34 }
35 35
36 public UserProfileData GetUserProfile(LLUUID avatarID) 36 public UserProfileData GetUserProfile(LLUUID avatarID)
37 { 37 {
38 return this.getUserProfile(avatarID); 38 return this.getUserProfile(avatarID);
39 } 39 }
40 40
41 /// <summary> 41 /// <summary>
42 /// 42 ///
43 /// </summary> 43 /// </summary>
44 /// <returns></returns> 44 /// <returns></returns>
45 public override string GetMessage() 45 public override string GetMessage()
46 { 46 {
47 return "Welcome to OpenSim"; 47 return "Welcome to OpenSim";
48 } 48 }
49 49
50 public override UserProfileData GetTheUser(string firstname, string lastname) 50 public override UserProfileData GetTheUser(string firstname, string lastname)
51 { 51 {
52 UserProfileData profile = getUserProfile(firstname, lastname); 52 UserProfileData profile = getUserProfile(firstname, lastname);
53 if (profile != null) 53 if (profile != null)
54 { 54 {
55 55
56 return profile; 56 return profile;
57 } 57 }
58 58
59 //no current user account so make one 59 //no current user account so make one
60 Console.WriteLine("No User account found so creating a new one "); 60 Console.WriteLine("No User account found so creating a new one ");
61 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); 61 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
62 62
63 profile = getUserProfile(firstname, lastname); 63 profile = getUserProfile(firstname, lastname);
64 64
65 return profile; 65 return profile;
66 } 66 }
67 67
68 public override bool AuthenticateUser(UserProfileData profile, string password) 68 public override bool AuthenticateUser(UserProfileData profile, string password)
69 { 69 {
70 //for now we will accept any password in sandbox mode 70 //for now we will accept any password in sandbox mode
71 Console.WriteLine("authorising user"); 71 Console.WriteLine("authorising user");
72 return true; 72 return true;
73 } 73 }
74 74
75 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) 75 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
76 { 76 {
77 ulong currentRegion = theUser.currentAgent.currentHandle; 77 ulong currentRegion = theUser.currentAgent.currentHandle;
78 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); 78 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
79 79
80 if (reg != null) 80 if (reg != null)
81 { 81 {
82 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + 82 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
83 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + 83 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
84 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; 84 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
85 string capsPath = Util.GetRandomCapsPath(); 85 string capsPath = Util.GetRandomCapsPath();
86 response.SimAddress = reg.ExternalEndPoint.Address.ToString(); 86 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
87 response.SimPort = (Int32)reg.ExternalEndPoint.Port; 87 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
88 response.RegionX = reg.RegionLocX ; 88 response.RegionX = reg.RegionLocX ;
89 response.RegionY = reg.RegionLocY ; 89 response.RegionY = reg.RegionLocY ;
90 90
91 //following port needs changing as we don't want a http listener for every region (or do we?) 91 //following port needs changing as we don't want a http listener for every region (or do we?)
92 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; 92 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
93 theUser.currentAgent.currentRegion = reg.SimUUID; 93 theUser.currentAgent.currentRegion = reg.SimUUID;
94 theUser.currentAgent.currentHandle = reg.RegionHandle; 94 theUser.currentAgent.currentHandle = reg.RegionHandle;
95 95
96 Login _login = new Login(); 96 Login _login = new Login();
97 //copy data to login object 97 //copy data to login object
98 _login.First = response.Firstname; 98 _login.First = response.Firstname;
99 _login.Last = response.Lastname; 99 _login.Last = response.Lastname;
100 _login.Agent = response.AgentID; 100 _login.Agent = response.AgentID;
101 _login.Session = response.SessionID; 101 _login.Session = response.SessionID;
102 _login.SecureSession = response.SecureSessionID; 102 _login.SecureSession = response.SecureSessionID;
103 _login.CircuitCode = (uint)response.CircuitCode; 103 _login.CircuitCode = (uint)response.CircuitCode;
104 _login.CapsPath = capsPath; 104 _login.CapsPath = capsPath;
105 105
106 m_Parent.InformRegionOfLogin(currentRegion, _login); 106 m_Parent.InformRegionOfLogin(currentRegion, _login);
107 } 107 }
108 else 108 else
109 { 109 {
110 Console.WriteLine("not found region " + currentRegion); 110 Console.WriteLine("not found region " + currentRegion);
111 } 111 }
112 112
113 } 113 }
114 114
115 public UserProfileData SetupMasterUser(string firstName, string lastName) 115 public UserProfileData SetupMasterUser(string firstName, string lastName)
116 { 116 {
117 return SetupMasterUser(firstName, lastName, ""); 117 return SetupMasterUser(firstName, lastName, "");
118 } 118 }
119 119
120 public UserProfileData SetupMasterUser(string firstName, string lastName, string password) 120 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
121 { 121 {
122 UserProfileData profile = getUserProfile(firstName, lastName); 122 UserProfileData profile = getUserProfile(firstName, lastName);
123 if (profile != null) 123 if (profile != null)
124 { 124 {
125 125
126 return profile; 126 return profile;
127 } 127 }
128 128
129 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account"); 129 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
130 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY); 130 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
131 131
132 profile = getUserProfile(firstName, lastName); 132 profile = getUserProfile(firstName, lastName);
133 133
134 if (profile == null) 134 if (profile == null)
135 { 135 {
136 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here."); 136 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
137 } 137 }
138 138
139 return profile; 139 return profile;
140 } 140 }
141 } 141 }
142} 142}
diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
index 9afb75e..ca64319 100644
--- a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
@@ -1,33 +1,33 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following 3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Region.Communications.Local")] 6[assembly: AssemblyTitle("OpenSim.Region.Communications.Local")]
7[assembly: AssemblyDescription("")] 7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")] 8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")] 9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")] 10[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")] 12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")] 13[assembly: AssemblyCulture("")]
14 14
15// Setting ComVisible to false makes the types in this assembly not visible 15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 18[assembly: ComVisible(false)]
19 19
20// The following GUID is for the ID of the typelib if this project is exposed to COM 20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")] 21[assembly: Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")]
22 22
23// Version information for an assembly consists of the following four values: 23// Version information for an assembly consists of the following four values:
24// 24//
25// Major Version 25// Major Version
26// Minor Version 26// Minor Version
27// Build Number 27// Build Number
28// Revision 28// Revision
29// 29//
30// You can specify all the values or you can default the Revision and Build Numbers 30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")] 33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
index cc05845..9df0901 100644
--- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
+++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
@@ -1,18 +1,18 @@
1using OpenSim.Framework.Communications; 1using OpenSim.Framework.Communications;
2using OpenSim.Framework.Types; 2using OpenSim.Framework.Types;
3using OpenSim.Framework.Servers; 3using OpenSim.Framework.Servers;
4 4
5namespace OpenSim.Region.Communications.OGS1 5namespace OpenSim.Region.Communications.OGS1
6{ 6{
7 public class CommunicationsOGS1 : CommunicationsManager 7 public class CommunicationsOGS1 : CommunicationsManager
8 { 8 {
9 9
10 public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) :base(serversInfo, httpServer) 10 public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) :base(serversInfo, httpServer)
11 { 11 {
12 OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); 12 OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer);
13 GridServer = gridInterComms; 13 GridServer = gridInterComms;
14 InterRegion = gridInterComms; 14 InterRegion = gridInterComms;
15 UserServer = new OGS1UserServices(this); 15 UserServer = new OGS1UserServices(this);
16 } 16 }
17 } 17 }
18} 18}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index e5a73fd..3cb2889 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -1,431 +1,431 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using System.Net; 4using System.Net;
5using System.Runtime.Remoting; 5using System.Runtime.Remoting;
6using System.Runtime.Remoting.Channels; 6using System.Runtime.Remoting.Channels;
7using System.Runtime.Remoting.Channels.Tcp; 7using System.Runtime.Remoting.Channels.Tcp;
8using libsecondlife; 8using libsecondlife;
9using Nwc.XmlRpc; 9using Nwc.XmlRpc;
10using OpenSim.Framework; 10using OpenSim.Framework;
11using OpenSim.Framework.Communications; 11using OpenSim.Framework.Communications;
12using OpenSim.Framework.Console; 12using OpenSim.Framework.Console;
13using OpenSim.Framework.Servers; 13using OpenSim.Framework.Servers;
14using OpenSim.Framework.Types; 14using OpenSim.Framework.Types;
15 15
16namespace OpenSim.Region.Communications.OGS1 16namespace OpenSim.Region.Communications.OGS1
17{ 17{
18 public class OGS1GridServices : IGridServices, IInterRegionCommunications 18 public class OGS1GridServices : IGridServices, IInterRegionCommunications
19 { 19 {
20 public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>(); 20 public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>();
21 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); 21 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
22 22
23 public BaseHttpServer httpListener; 23 public BaseHttpServer httpListener;
24 public NetworkServersInfo serversInfo; 24 public NetworkServersInfo serversInfo;
25 public BaseHttpServer httpServer; 25 public BaseHttpServer httpServer;
26 26
27 /// <summary> 27 /// <summary>
28 /// 28 ///
29 /// </summary> 29 /// </summary>
30 /// <param name="servers_info"></param> 30 /// <param name="servers_info"></param>
31 /// <param name="httpServe"></param> 31 /// <param name="httpServe"></param>
32 public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe) 32 public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe)
33 { 33 {
34 serversInfo = servers_info; 34 serversInfo = servers_info;
35 httpServer = httpServe; 35 httpServer = httpServe;
36 httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); 36 httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser);
37 this.StartRemoting(); 37 this.StartRemoting();
38 } 38 }
39 39
40 /// <summary> 40 /// <summary>
41 /// 41 ///
42 /// </summary> 42 /// </summary>
43 /// <param name="regionInfo"></param> 43 /// <param name="regionInfo"></param>
44 /// <returns></returns> 44 /// <returns></returns>
45 public RegionCommsListener RegisterRegion(RegionInfo regionInfo) 45 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
46 { 46 {
47 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) 47 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
48 { 48 {
49 this.regions.Add(regionInfo.RegionHandle, regionInfo); 49 this.regions.Add(regionInfo.RegionHandle, regionInfo);
50 } 50 }
51 51
52 Hashtable GridParams = new Hashtable(); 52 Hashtable GridParams = new Hashtable();
53 // Login / Authentication 53 // Login / Authentication
54 54
55 GridParams["authkey"] = serversInfo.GridSendKey; 55 GridParams["authkey"] = serversInfo.GridSendKey;
56 GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); 56 GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated();
57 GridParams["sim_ip"] = regionInfo.ExternalHostName; 57 GridParams["sim_ip"] = regionInfo.ExternalHostName;
58 GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); 58 GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
59 GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); 59 GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
60 GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); 60 GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
61 GridParams["sim_name"] = regionInfo.RegionName; 61 GridParams["sim_name"] = regionInfo.RegionName;
62 GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); 62 GridParams["http_port"] = serversInfo.HttpListenerPort.ToString();
63 GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); 63 GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString();
64 GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); 64 GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated();
65 65
66 // Package into an XMLRPC Request 66 // Package into an XMLRPC Request
67 ArrayList SendParams = new ArrayList(); 67 ArrayList SendParams = new ArrayList();
68 SendParams.Add(GridParams); 68 SendParams.Add(GridParams);
69 69
70 // Send Request 70 // Send Request
71 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); 71 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
72 XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); 72 XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
73 Hashtable GridRespData = (Hashtable)GridResp.Value; 73 Hashtable GridRespData = (Hashtable)GridResp.Value;
74 74
75 Hashtable griddatahash = GridRespData; 75 Hashtable griddatahash = GridRespData;
76 76
77 // Process Response 77 // Process Response
78 if (GridRespData.ContainsKey("error")) 78 if (GridRespData.ContainsKey("error"))
79 { 79 {
80 string errorstring = (string)GridRespData["error"]; 80 string errorstring = (string)GridRespData["error"];
81 MainLog.Instance.Error("Unable to connect to grid: " + errorstring); 81 MainLog.Instance.Error("Unable to connect to grid: " + errorstring);
82 return null; 82 return null;
83 } 83 }
84 84
85 // Initialise the background listeners 85 // Initialise the background listeners
86 RegionCommsListener regListener = new RegionCommsListener(); 86 RegionCommsListener regListener = new RegionCommsListener();
87 if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) 87 if (!this.listeners.ContainsKey(regionInfo.RegionHandle))
88 { 88 {
89 this.listeners.Add(regionInfo.RegionHandle, regListener); 89 this.listeners.Add(regionInfo.RegionHandle, regListener);
90 } 90 }
91 else 91 else
92 { 92 {
93 listeners[regionInfo.RegionHandle] = regListener; 93 listeners[regionInfo.RegionHandle] = regListener;
94 } 94 }
95 95
96 return regListener; 96 return regListener;
97 } 97 }
98 98
99 /// <summary> 99 /// <summary>
100 /// 100 ///
101 /// </summary> 101 /// </summary>
102 /// <param name="regionInfo"></param> 102 /// <param name="regionInfo"></param>
103 /// <returns></returns> 103 /// <returns></returns>
104 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) 104 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
105 { 105 {
106 106
107 Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); 107 Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1);
108 108
109 List<RegionInfo> neighbours = new List<RegionInfo>(); 109 List<RegionInfo> neighbours = new List<RegionInfo>();
110 110
111 foreach (ArrayList a in respData.Values) 111 foreach (ArrayList a in respData.Values)
112 { 112 {
113 foreach (Hashtable n in a) 113 foreach (Hashtable n in a)
114 { 114 {
115 uint regX = Convert.ToUInt32(n["x"]); 115 uint regX = Convert.ToUInt32(n["x"]);
116 uint regY = Convert.ToUInt32(n["y"]); 116 uint regY = Convert.ToUInt32(n["y"]);
117 if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) 117 if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY))
118 { 118 {
119 string externalIpStr = (string)n["sim_ip"]; 119 string externalIpStr = (string)n["sim_ip"];
120 uint port = Convert.ToUInt32(n["sim_port"]); 120 uint port = Convert.ToUInt32(n["sim_port"]);
121 string externalUri = (string)n["sim_uri"]; 121 string externalUri = (string)n["sim_uri"];
122 122
123 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port); 123 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port);
124 string neighbourExternalUri = externalUri; 124 string neighbourExternalUri = externalUri;
125 RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr); 125 RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr);
126 126
127 //OGS1 127 //OGS1
128 //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally 128 //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally
129 129
130 neighbour.RegionName = (string)n["name"]; 130 neighbour.RegionName = (string)n["name"];
131 131
132 //OGS1+ 132 //OGS1+
133 neighbour.SimUUID = (string)n["uuid"]; 133 neighbour.SimUUID = (string)n["uuid"];
134 134
135 neighbours.Add(neighbour); 135 neighbours.Add(neighbour);
136 } 136 }
137 } 137 }
138 } 138 }
139 139
140 return neighbours; 140 return neighbours;
141 } 141 }
142 142
143 /// <summary> 143 /// <summary>
144 /// 144 ///
145 /// </summary> 145 /// </summary>
146 /// <param name="regionHandle"></param> 146 /// <param name="regionHandle"></param>
147 /// <returns></returns> 147 /// <returns></returns>
148 public RegionInfo RequestNeighbourInfo(ulong regionHandle) 148 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
149 { 149 {
150 if (this.regions.ContainsKey(regionHandle)) 150 if (this.regions.ContainsKey(regionHandle))
151 { 151 {
152 return this.regions[regionHandle]; 152 return this.regions[regionHandle];
153 } 153 }
154 //TODO not a region in this instance so ask remote grid server 154 //TODO not a region in this instance so ask remote grid server
155 155
156 Hashtable requestData = new Hashtable(); 156 Hashtable requestData = new Hashtable();
157 requestData["region_handle"] = regionHandle.ToString(); 157 requestData["region_handle"] = regionHandle.ToString();
158 requestData["authkey"] = this.serversInfo.GridSendKey; 158 requestData["authkey"] = this.serversInfo.GridSendKey;
159 ArrayList SendParams = new ArrayList(); 159 ArrayList SendParams = new ArrayList();
160 SendParams.Add(requestData); 160 SendParams.Add(requestData);
161 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); 161 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
162 XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); 162 XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000);
163 163
164 Hashtable responseData = (Hashtable)GridResp.Value; 164 Hashtable responseData = (Hashtable)GridResp.Value;
165 165
166 if (responseData.ContainsKey("error")) 166 if (responseData.ContainsKey("error"))
167 { 167 {
168 Console.WriteLine("error received from grid server" + responseData["error"]); 168 Console.WriteLine("error received from grid server" + responseData["error"]);
169 return null; 169 return null;
170 } 170 }
171 171
172 uint regX = Convert.ToUInt32((string)responseData["region_locx"]); 172 uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
173 uint regY = Convert.ToUInt32((string)responseData["region_locy"]); 173 uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
174 string internalIpStr = (string)responseData["sim_ip"]; 174 string internalIpStr = (string)responseData["sim_ip"];
175 uint port = Convert.ToUInt32(responseData["sim_port"]); 175 uint port = Convert.ToUInt32(responseData["sim_port"]);
176 string externalUri = (string)responseData["sim_uri"]; 176 string externalUri = (string)responseData["sim_uri"];
177 177
178 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); 178 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port);
179 string neighbourExternalUri = externalUri; 179 string neighbourExternalUri = externalUri;
180 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); 180 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
181 181
182 regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); 182 regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
183 regionInfo.RemotingAddress = internalIpStr; 183 regionInfo.RemotingAddress = internalIpStr;
184 184
185 regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]); 185 regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]);
186 regionInfo.RegionName = (string)responseData["region_name"]; 186 regionInfo.RegionName = (string)responseData["region_name"];
187 187
188 return regionInfo; 188 return regionInfo;
189 } 189 }
190 190
191 /// <summary> 191 /// <summary>
192 /// 192 ///
193 /// </summary> 193 /// </summary>
194 /// <param name="minX"></param> 194 /// <param name="minX"></param>
195 /// <param name="minY"></param> 195 /// <param name="minY"></param>
196 /// <param name="maxX"></param> 196 /// <param name="maxX"></param>
197 /// <param name="maxY"></param> 197 /// <param name="maxY"></param>
198 /// <returns></returns> 198 /// <returns></returns>
199 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) 199 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
200 { 200 {
201 Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY); 201 Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
202 202
203 List<MapBlockData> neighbours = new List<MapBlockData>(); 203 List<MapBlockData> neighbours = new List<MapBlockData>();
204 204
205 foreach (ArrayList a in respData.Values) 205 foreach (ArrayList a in respData.Values)
206 { 206 {
207 foreach (Hashtable n in a) 207 foreach (Hashtable n in a)
208 { 208 {
209 MapBlockData neighbour = new MapBlockData(); 209 MapBlockData neighbour = new MapBlockData();
210 210
211 neighbour.X = Convert.ToUInt16(n["x"]); 211 neighbour.X = Convert.ToUInt16(n["x"]);
212 neighbour.Y = Convert.ToUInt16(n["y"]); 212 neighbour.Y = Convert.ToUInt16(n["y"]);
213 213
214 neighbour.Name = (string)n["name"]; 214 neighbour.Name = (string)n["name"];
215 neighbour.Access = Convert.ToByte(n["access"]); 215 neighbour.Access = Convert.ToByte(n["access"]);
216 neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); 216 neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]);
217 neighbour.WaterHeight = Convert.ToByte(n["water-height"]); 217 neighbour.WaterHeight = Convert.ToByte(n["water-height"]);
218 neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); 218 neighbour.MapImageId = new LLUUID((string)n["map-image-id"]);
219 219
220 neighbours.Add(neighbour); 220 neighbours.Add(neighbour);
221 } 221 }
222 } 222 }
223 223
224 return neighbours; 224 return neighbours;
225 } 225 }
226 226
227 /// <summary> 227 /// <summary>
228 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates 228 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
229 /// </summary> 229 /// </summary>
230 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks> 230 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
231 /// <param name="minX">Minimum X value</param> 231 /// <param name="minX">Minimum X value</param>
232 /// <param name="minY">Minimum Y value</param> 232 /// <param name="minY">Minimum Y value</param>
233 /// <param name="maxX">Maximum X value</param> 233 /// <param name="maxX">Maximum X value</param>
234 /// <param name="maxY">Maximum Y value</param> 234 /// <param name="maxY">Maximum Y value</param>
235 /// <returns>Hashtable of hashtables containing map data elements</returns> 235 /// <returns>Hashtable of hashtables containing map data elements</returns>
236 private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY) 236 private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
237 { 237 {
238 Hashtable param = new Hashtable(); 238 Hashtable param = new Hashtable();
239 param["xmin"] = minX; 239 param["xmin"] = minX;
240 param["ymin"] = minY; 240 param["ymin"] = minY;
241 param["xmax"] = maxX; 241 param["xmax"] = maxX;
242 param["ymax"] = maxY; 242 param["ymax"] = maxY;
243 IList parameters = new ArrayList(); 243 IList parameters = new ArrayList();
244 parameters.Add(param); 244 parameters.Add(param);
245 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); 245 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
246 XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000); 246 XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000);
247 Hashtable respData = (Hashtable)resp.Value; 247 Hashtable respData = (Hashtable)resp.Value;
248 return respData; 248 return respData;
249 } 249 }
250 250
251 // Grid Request Processing 251 // Grid Request Processing
252 /// <summary> 252 /// <summary>
253 /// 253 ///
254 /// </summary> 254 /// </summary>
255 /// <param name="request"></param> 255 /// <param name="request"></param>
256 /// <returns></returns> 256 /// <returns></returns>
257 public XmlRpcResponse ExpectUser(XmlRpcRequest request) 257 public XmlRpcResponse ExpectUser(XmlRpcRequest request)
258 { 258 {
259 Console.WriteLine("Expecting User..."); 259 Console.WriteLine("Expecting User...");
260 Hashtable requestData = (Hashtable)request.Params[0]; 260 Hashtable requestData = (Hashtable)request.Params[0];
261 AgentCircuitData agentData = new AgentCircuitData(); 261 AgentCircuitData agentData = new AgentCircuitData();
262 agentData.SessionID = new LLUUID((string)requestData["session_id"]); 262 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
263 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); 263 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
264 agentData.firstname = (string)requestData["firstname"]; 264 agentData.firstname = (string)requestData["firstname"];
265 agentData.lastname = (string)requestData["lastname"]; 265 agentData.lastname = (string)requestData["lastname"];
266 agentData.AgentID = new LLUUID((string)requestData["agent_id"]); 266 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
267 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); 267 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
268 agentData.CapsPath = (string)requestData["caps_path"]; 268 agentData.CapsPath = (string)requestData["caps_path"];
269 269
270 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) 270 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
271 { 271 {
272 agentData.child = true; 272 agentData.child = true;
273 } 273 }
274 else 274 else
275 { 275 {
276 agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"])); 276 agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
277 agentData.child = false; 277 agentData.child = false;
278 278
279 } 279 }
280 280
281 if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"]))) 281 if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"])))
282 { 282 {
283 this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData); 283 this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData);
284 } 284 }
285 else 285 else
286 { 286 {
287 MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString()); 287 MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString());
288 } 288 }
289 289
290 MainLog.Instance.Verbose("ExpectUser() - Welcoming new user..."); 290 MainLog.Instance.Verbose("ExpectUser() - Welcoming new user...");
291 291
292 return new XmlRpcResponse(); 292 return new XmlRpcResponse();
293 } 293 }
294 294
295 #region InterRegion Comms 295 #region InterRegion Comms
296 /// <summary> 296 /// <summary>
297 /// 297 ///
298 /// </summary> 298 /// </summary>
299 private void StartRemoting() 299 private void StartRemoting()
300 { 300 {
301 TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort); 301 TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort);
302 ChannelServices.RegisterChannel(ch, true); 302 ChannelServices.RegisterChannel(ch, true);
303 303
304 WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); 304 WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton);
305 RemotingConfiguration.RegisterWellKnownServiceType(wellType); 305 RemotingConfiguration.RegisterWellKnownServiceType(wellType);
306 InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; 306 InterRegionSingleton.Instance.OnArrival += this.IncomingArrival;
307 InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; 307 InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent;
308 } 308 }
309 309
310 #region Methods called by regions in this instance 310 #region Methods called by regions in this instance
311 /// <summary> 311 /// <summary>
312 /// 312 ///
313 /// </summary> 313 /// </summary>
314 /// <param name="regionHandle"></param> 314 /// <param name="regionHandle"></param>
315 /// <param name="agentData"></param> 315 /// <param name="agentData"></param>
316 /// <returns></returns> 316 /// <returns></returns>
317 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) 317 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
318 { 318 {
319 if (this.listeners.ContainsKey(regionHandle)) 319 if (this.listeners.ContainsKey(regionHandle))
320 { 320 {
321 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); 321 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
322 return true; 322 return true;
323 } 323 }
324 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); 324 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
325 if (regInfo != null) 325 if (regInfo != null)
326 { 326 {
327 //don't want to be creating a new link to the remote instance every time like we are here 327 //don't want to be creating a new link to the remote instance every time like we are here
328 bool retValue = false; 328 bool retValue = false;
329 329
330 330
331 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 331 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
332 typeof(OGS1InterRegionRemoting), 332 typeof(OGS1InterRegionRemoting),
333 "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions"); 333 "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions");
334 if (remObject != null) 334 if (remObject != null)
335 { 335 {
336 336
337 retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); 337 retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData);
338 } 338 }
339 else 339 else
340 { 340 {
341 Console.WriteLine("remoting object not found"); 341 Console.WriteLine("remoting object not found");
342 } 342 }
343 remObject = null; 343 remObject = null;
344 344
345 345
346 return retValue; 346 return retValue;
347 } 347 }
348 348
349 return false; 349 return false;
350 } 350 }
351 351
352 /// <summary> 352 /// <summary>
353 /// 353 ///
354 /// </summary> 354 /// </summary>
355 /// <param name="regionHandle"></param> 355 /// <param name="regionHandle"></param>
356 /// <param name="agentID"></param> 356 /// <param name="agentID"></param>
357 /// <param name="position"></param> 357 /// <param name="position"></param>
358 /// <returns></returns> 358 /// <returns></returns>
359 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 359 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
360 { 360 {
361 if (this.listeners.ContainsKey(regionHandle)) 361 if (this.listeners.ContainsKey(regionHandle))
362 { 362 {
363 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); 363 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
364 return true; 364 return true;
365 } 365 }
366 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); 366 RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle);
367 if (regInfo != null) 367 if (regInfo != null)
368 { 368 {
369 bool retValue = false; 369 bool retValue = false;
370 370
371 371
372 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 372 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
373 typeof(OGS1InterRegionRemoting), 373 typeof(OGS1InterRegionRemoting),
374 "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); 374 "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions");
375 if (remObject != null) 375 if (remObject != null)
376 { 376 {
377 377
378 retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); 378 retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position);
379 } 379 }
380 else 380 else
381 { 381 {
382 Console.WriteLine("remoting object not found"); 382 Console.WriteLine("remoting object not found");
383 } 383 }
384 remObject = null; 384 remObject = null;
385 385
386 386
387 return retValue; 387 return retValue;
388 } 388 }
389 //TODO need to see if we know about where this region is and use .net remoting 389 //TODO need to see if we know about where this region is and use .net remoting
390 // to inform it. 390 // to inform it.
391 return false; 391 return false;
392 } 392 }
393 #endregion 393 #endregion
394 394
395 #region Methods triggered by calls from external instances 395 #region Methods triggered by calls from external instances
396 /// <summary> 396 /// <summary>
397 /// 397 ///
398 /// </summary> 398 /// </summary>
399 /// <param name="regionHandle"></param> 399 /// <param name="regionHandle"></param>
400 /// <param name="agentData"></param> 400 /// <param name="agentData"></param>
401 /// <returns></returns> 401 /// <returns></returns>
402 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) 402 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
403 { 403 {
404 if (this.listeners.ContainsKey(regionHandle)) 404 if (this.listeners.ContainsKey(regionHandle))
405 { 405 {
406 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); 406 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData);
407 return true; 407 return true;
408 } 408 }
409 return false; 409 return false;
410 } 410 }
411 411
412 /// <summary> 412 /// <summary>
413 /// 413 ///
414 /// </summary> 414 /// </summary>
415 /// <param name="regionHandle"></param> 415 /// <param name="regionHandle"></param>
416 /// <param name="agentID"></param> 416 /// <param name="agentID"></param>
417 /// <param name="position"></param> 417 /// <param name="position"></param>
418 /// <returns></returns> 418 /// <returns></returns>
419 public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position) 419 public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position)
420 { 420 {
421 if (this.listeners.ContainsKey(regionHandle)) 421 if (this.listeners.ContainsKey(regionHandle))
422 { 422 {
423 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); 423 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
424 return true; 424 return true;
425 } 425 }
426 return false; 426 return false;
427 } 427 }
428 #endregion 428 #endregion
429 #endregion 429 #endregion
430 } 430 }
431} 431}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
index f514a29..520c593 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs
@@ -1,69 +1,69 @@
1using System; 1using System;
2using libsecondlife; 2using libsecondlife;
3using OpenSim.Framework.Types; 3using OpenSim.Framework.Types;
4 4
5namespace OpenSim.Region.Communications.OGS1 5namespace OpenSim.Region.Communications.OGS1
6{ 6{
7 public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData); 7 public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData);
8 public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position); 8 public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position);
9 9
10 public sealed class InterRegionSingleton 10 public sealed class InterRegionSingleton
11 { 11 {
12 static readonly InterRegionSingleton instance = new InterRegionSingleton(); 12 static readonly InterRegionSingleton instance = new InterRegionSingleton();
13 13
14 public event InformRegionChild OnChildAgent; 14 public event InformRegionChild OnChildAgent;
15 public event ExpectArrival OnArrival; 15 public event ExpectArrival OnArrival;
16 16
17 static InterRegionSingleton() 17 static InterRegionSingleton()
18 { 18 {
19 } 19 }
20 20
21 InterRegionSingleton() 21 InterRegionSingleton()
22 { 22 {
23 } 23 }
24 24
25 public static InterRegionSingleton Instance 25 public static InterRegionSingleton Instance
26 { 26 {
27 get 27 get
28 { 28 {
29 return instance; 29 return instance;
30 } 30 }
31 } 31 }
32 32
33 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) 33 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
34 { 34 {
35 if (OnChildAgent != null) 35 if (OnChildAgent != null)
36 { 36 {
37 return OnChildAgent(regionHandle, agentData); 37 return OnChildAgent(regionHandle, agentData);
38 } 38 }
39 return false; 39 return false;
40 } 40 }
41 41
42 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 42 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
43 { 43 {
44 if (OnArrival != null) 44 if (OnArrival != null)
45 { 45 {
46 return OnArrival(regionHandle, agentID, position); 46 return OnArrival(regionHandle, agentID, position);
47 } 47 }
48 return false; 48 return false;
49 } 49 }
50 } 50 }
51 51
52 public class OGS1InterRegionRemoting : MarshalByRefObject 52 public class OGS1InterRegionRemoting : MarshalByRefObject
53 { 53 {
54 54
55 public OGS1InterRegionRemoting() 55 public OGS1InterRegionRemoting()
56 { 56 {
57 } 57 }
58 58
59 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) 59 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
60 { 60 {
61 return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData); 61 return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData);
62 } 62 }
63 63
64 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 64 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
65 { 65 {
66 return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position); 66 return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position);
67 } 67 }
68 } 68 }
69} 69}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 46d71c4..0847148 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -1,101 +1,101 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using libsecondlife; 3using libsecondlife;
4using Nwc.XmlRpc; 4using Nwc.XmlRpc;
5using OpenSim.Framework.Communications; 5using OpenSim.Framework.Communications;
6using OpenSim.Framework.Data; 6using OpenSim.Framework.Data;
7 7
8namespace OpenSim.Region.Communications.OGS1 8namespace OpenSim.Region.Communications.OGS1
9{ 9{
10 public class OGS1UserServices :IUserServices 10 public class OGS1UserServices :IUserServices
11 { 11 {
12 CommunicationsOGS1 m_parent; 12 CommunicationsOGS1 m_parent;
13 public OGS1UserServices(CommunicationsOGS1 parent) 13 public OGS1UserServices(CommunicationsOGS1 parent)
14 { 14 {
15 m_parent = parent; 15 m_parent = parent;
16 } 16 }
17 17
18 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) 18 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
19 { 19 {
20 if (data.Contains("error_type")) 20 if (data.Contains("error_type"))
21 { 21 {
22 Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]); 22 Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]);
23 return null; 23 return null;
24 } 24 }
25 25
26 UserProfileData userData = new UserProfileData(); 26 UserProfileData userData = new UserProfileData();
27 userData.username = (string)data["firstname"]; 27 userData.username = (string)data["firstname"];
28 userData.surname = (string)data["lastname"]; 28 userData.surname = (string)data["lastname"];
29 userData.UUID = new LLUUID((string)data["uuid"]); 29 userData.UUID = new LLUUID((string)data["uuid"]);
30 userData.userInventoryURI = (string)data["server_inventory"]; 30 userData.userInventoryURI = (string)data["server_inventory"];
31 userData.userAssetURI = (string)data["server_asset"]; 31 userData.userAssetURI = (string)data["server_asset"];
32 userData.profileFirstText = (string)data["profile_firstlife_about"]; 32 userData.profileFirstText = (string)data["profile_firstlife_about"];
33 userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]); 33 userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]);
34 userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); 34 userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
35 userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]); 35 userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]);
36 userData.profileImage = new LLUUID((string)data["profile_image"]); 36 userData.profileImage = new LLUUID((string)data["profile_image"]);
37 userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]); 37 userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
38 userData.homeRegion = Convert.ToUInt64((string)data["home_region"]); 38 userData.homeRegion = Convert.ToUInt64((string)data["home_region"]);
39 userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"])); 39 userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
40 userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"])); 40 userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"]));
41 41
42 return userData; 42 return userData;
43 } 43 }
44 public UserProfileData GetUserProfile(string firstName, string lastName) 44 public UserProfileData GetUserProfile(string firstName, string lastName)
45 { 45 {
46 return GetUserProfile(firstName + " " + lastName); 46 return GetUserProfile(firstName + " " + lastName);
47 } 47 }
48 public UserProfileData GetUserProfile(string name) 48 public UserProfileData GetUserProfile(string name)
49 { 49 {
50 //try 50 //try
51 //{ 51 //{
52 Hashtable param = new Hashtable(); 52 Hashtable param = new Hashtable();
53 param["avatar_name"] = name; 53 param["avatar_name"] = name;
54 IList parameters = new ArrayList(); 54 IList parameters = new ArrayList();
55 parameters.Add(param); 55 parameters.Add(param);
56 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); 56 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
57 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000); 57 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
58 Hashtable respData = (Hashtable)resp.Value; 58 Hashtable respData = (Hashtable)resp.Value;
59 59
60 return ConvertXMLRPCDataToUserProfile(respData); 60 return ConvertXMLRPCDataToUserProfile(respData);
61 //} 61 //}
62 //catch (Exception e) 62 //catch (Exception e)
63 //{ 63 //{
64 // Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message); 64 // Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message);
65 //} 65 //}
66 //return null; 66 //return null;
67 } 67 }
68 public UserProfileData GetUserProfile(LLUUID avatarID) 68 public UserProfileData GetUserProfile(LLUUID avatarID)
69 { 69 {
70 try 70 try
71 { 71 {
72 72
73 Hashtable param = new Hashtable(); 73 Hashtable param = new Hashtable();
74 param["avatar_uuid"] = avatarID.ToString(); 74 param["avatar_uuid"] = avatarID.ToString();
75 IList parameters = new ArrayList(); 75 IList parameters = new ArrayList();
76 parameters.Add(param); 76 parameters.Add(param);
77 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); 77 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
78 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000); 78 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
79 Hashtable respData = (Hashtable)resp.Value; 79 Hashtable respData = (Hashtable)resp.Value;
80 80
81 return ConvertXMLRPCDataToUserProfile(respData); 81 return ConvertXMLRPCDataToUserProfile(respData);
82 } 82 }
83 catch (Exception e) 83 catch (Exception e)
84 { 84 {
85 Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message); 85 Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message);
86 } 86 }
87 return null; 87 return null;
88 } 88 }
89 89
90 public UserProfileData SetupMasterUser(string firstName, string lastName) 90 public UserProfileData SetupMasterUser(string firstName, string lastName)
91 { 91 {
92 return SetupMasterUser(firstName, lastName, ""); 92 return SetupMasterUser(firstName, lastName, "");
93 } 93 }
94 94
95 public UserProfileData SetupMasterUser(string firstName, string lastName, string password) 95 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
96 { 96 {
97 UserProfileData profile = GetUserProfile(firstName, lastName); 97 UserProfileData profile = GetUserProfile(firstName, lastName);
98 return profile; 98 return profile;
99 } 99 }
100 } 100 }
101} 101}
diff --git a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
index 41f811a..2bebf9f 100644
--- a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs
@@ -1,33 +1,33 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following 3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 5// associated with an assembly.
6[assembly: AssemblyTitle("OpenGrid.Framework.Communications.OGS1")] 6[assembly: AssemblyTitle("OpenGrid.Framework.Communications.OGS1")]
7[assembly: AssemblyDescription("")] 7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")] 8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")] 9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")] 10[assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")]
11[assembly: AssemblyCopyright("Copyright © 2007")] 11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")] 12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")] 13[assembly: AssemblyCulture("")]
14 14
15// Setting ComVisible to false makes the types in this assembly not visible 15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 18[assembly: ComVisible(false)]
19 19
20// The following GUID is for the ID of the typelib if this project is exposed to COM 20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")] 21[assembly: Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")]
22 22
23// Version information for an assembly consists of the following four values: 23// Version information for an assembly consists of the following four values:
24// 24//
25// Major Version 25// Major Version
26// Minor Version 26// Minor Version
27// Build Number 27// Build Number
28// Revision 28// Revision
29// 29//
30// You can specify all the values or you can default the Revision and Build Numbers 30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below: 31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")] 32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")] 33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
index de0b040..3742486 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -1,299 +1,299 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using libsecondlife; 31using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; 37using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
38 38
39 39
40namespace OpenSim.Region.Environment 40namespace OpenSim.Region.Environment
41{ 41{
42 42
43 /// <summary> 43 /// <summary>
44 /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings 44 /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
45 /// </summary> 45 /// </summary>
46 public class EstateManager 46 public class EstateManager
47 { 47 {
48 private Scene m_world; 48 private Scene m_world;
49 private RegionInfo m_regInfo; 49 private RegionInfo m_regInfo;
50 50
51 public EstateManager(Scene world,RegionInfo reginfo) 51 public EstateManager(Scene world,RegionInfo reginfo)
52 { 52 {
53 m_world = world; //Estate settings found at world.m_regInfo.estateSettings 53 m_world = world; //Estate settings found at world.m_regInfo.estateSettings
54 m_regInfo = reginfo; 54 m_regInfo = reginfo;
55 } 55 }
56 56
57 private bool convertParamStringToBool(byte[] field) 57 private bool convertParamStringToBool(byte[] field)
58 { 58 {
59 string s = Helpers.FieldToUTF8String(field); 59 string s = Helpers.FieldToUTF8String(field);
60 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true") 60 if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
61 { 61 {
62 return true; 62 return true;
63 } 63 }
64 return false; 64 return false;
65 } 65 }
66 66
67 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client) 67 public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
68 { 68 {
69 if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID) 69 if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID)
70 { 70 {
71 switch (Helpers.FieldToUTF8String(packet.MethodData.Method)) 71 switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
72 { 72 {
73 case "getinfo": 73 case "getinfo":
74 this.sendRegionInfoPacketToAll(); 74 this.sendRegionInfoPacketToAll();
75 75
76 break; 76 break;
77 case "setregioninfo": 77 case "setregioninfo":
78 if (packet.ParamList.Length != 9) 78 if (packet.ParamList.Length != 9)
79 { 79 {
80 MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length"); 80 MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
81 } 81 }
82 else 82 else
83 { 83 {
84 m_regInfo.estateSettings.regionFlags = Simulator.RegionFlags.None; 84 m_regInfo.estateSettings.regionFlags = Simulator.RegionFlags.None;
85 85
86 if (convertParamStringToBool(packet.ParamList[0].Parameter)) 86 if (convertParamStringToBool(packet.ParamList[0].Parameter))
87 { 87 {
88 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform; 88 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform;
89 } 89 }
90 90
91 if (convertParamStringToBool(packet.ParamList[1].Parameter)) 91 if (convertParamStringToBool(packet.ParamList[1].Parameter))
92 { 92 {
93 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly; 93 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly;
94 } 94 }
95 95
96 if (convertParamStringToBool(packet.ParamList[2].Parameter)) 96 if (convertParamStringToBool(packet.ParamList[2].Parameter))
97 { 97 {
98 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage; 98 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage;
99 } 99 }
100 100
101 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false) 101 if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
102 { 102 {
103 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell; 103 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell;
104 } 104 }
105 105
106 106
107 int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); 107 int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
108 m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents; 108 m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents;
109 109
110 float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); 110 float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
111 m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor; 111 m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor;
112 112
113 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); 113 int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
114 m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel; 114 m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel;
115 115
116 116
117 if (convertParamStringToBool(packet.ParamList[7].Parameter)) 117 if (convertParamStringToBool(packet.ParamList[7].Parameter))
118 { 118 {
119 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject; 119 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject;
120 } 120 }
121 121
122 if (convertParamStringToBool(packet.ParamList[8].Parameter)) 122 if (convertParamStringToBool(packet.ParamList[8].Parameter))
123 { 123 {
124 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges; 124 m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges;
125 } 125 }
126 126
127 sendRegionInfoPacketToAll(); 127 sendRegionInfoPacketToAll();
128 128
129 } 129 }
130 break; 130 break;
131 case "texturebase": 131 case "texturebase":
132 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) 132 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
133 { 133 {
134 string s = Helpers.FieldToUTF8String(block.Parameter); 134 string s = Helpers.FieldToUTF8String(block.Parameter);
135 string[] splitField = s.Split(' '); 135 string[] splitField = s.Split(' ');
136 if (splitField.Length == 2) 136 if (splitField.Length == 2)
137 { 137 {
138 LLUUID tempUUID = new LLUUID(splitField[1]); 138 LLUUID tempUUID = new LLUUID(splitField[1]);
139 switch (Convert.ToInt16(splitField[0])) 139 switch (Convert.ToInt16(splitField[0]))
140 { 140 {
141 case 0: 141 case 0:
142 m_regInfo.estateSettings.terrainBase0 = tempUUID; 142 m_regInfo.estateSettings.terrainBase0 = tempUUID;
143 break; 143 break;
144 case 1: 144 case 1:
145 m_regInfo.estateSettings.terrainBase1 = tempUUID; 145 m_regInfo.estateSettings.terrainBase1 = tempUUID;
146 break; 146 break;
147 case 2: 147 case 2:
148 m_regInfo.estateSettings.terrainBase2 = tempUUID; 148 m_regInfo.estateSettings.terrainBase2 = tempUUID;
149 break; 149 break;
150 case 3: 150 case 3:
151 m_regInfo.estateSettings.terrainBase3 = tempUUID; 151 m_regInfo.estateSettings.terrainBase3 = tempUUID;
152 break; 152 break;
153 } 153 }
154 } 154 }
155 } 155 }
156 break; 156 break;
157 case "texturedetail": 157 case "texturedetail":
158 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) 158 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
159 { 159 {
160 160
161 string s = Helpers.FieldToUTF8String(block.Parameter); 161 string s = Helpers.FieldToUTF8String(block.Parameter);
162 string[] splitField = s.Split(' '); 162 string[] splitField = s.Split(' ');
163 if (splitField.Length == 2) 163 if (splitField.Length == 2)
164 { 164 {
165 LLUUID tempUUID = new LLUUID(splitField[1]); 165 LLUUID tempUUID = new LLUUID(splitField[1]);
166 switch (Convert.ToInt16(splitField[0])) 166 switch (Convert.ToInt16(splitField[0]))
167 { 167 {
168 case 0: 168 case 0:
169 m_regInfo.estateSettings.terrainDetail0 = tempUUID; 169 m_regInfo.estateSettings.terrainDetail0 = tempUUID;
170 break; 170 break;
171 case 1: 171 case 1:
172 m_regInfo.estateSettings.terrainDetail1 = tempUUID; 172 m_regInfo.estateSettings.terrainDetail1 = tempUUID;
173 break; 173 break;
174 case 2: 174 case 2:
175 m_regInfo.estateSettings.terrainDetail2 = tempUUID; 175 m_regInfo.estateSettings.terrainDetail2 = tempUUID;
176 break; 176 break;
177 case 3: 177 case 3:
178 m_regInfo.estateSettings.terrainDetail3 = tempUUID; 178 m_regInfo.estateSettings.terrainDetail3 = tempUUID;
179 break; 179 break;
180 } 180 }
181 } 181 }
182 } 182 }
183 break; 183 break;
184 case "textureheights": 184 case "textureheights":
185 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) 185 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
186 { 186 {
187 187
188 string s = Helpers.FieldToUTF8String(block.Parameter); 188 string s = Helpers.FieldToUTF8String(block.Parameter);
189 string[] splitField = s.Split(' '); 189 string[] splitField = s.Split(' ');
190 if (splitField.Length == 3) 190 if (splitField.Length == 3)
191 { 191 {
192 192
193 float tempHeightLow = (float)Convert.ToDecimal(splitField[1]); 193 float tempHeightLow = (float)Convert.ToDecimal(splitField[1]);
194 float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]); 194 float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]);
195 195
196 switch (Convert.ToInt16(splitField[0])) 196 switch (Convert.ToInt16(splitField[0]))
197 { 197 {
198 case 0: 198 case 0:
199 m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow; 199 m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow;
200 m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh; 200 m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh;
201 break; 201 break;
202 case 1: 202 case 1:
203 m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow; 203 m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow;
204 m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh; 204 m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh;
205 break; 205 break;
206 case 2: 206 case 2:
207 m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow; 207 m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow;
208 m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh; 208 m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh;
209 break; 209 break;
210 case 3: 210 case 3:
211 m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow; 211 m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow;
212 m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh; 212 m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh;
213 break; 213 break;
214 } 214 }
215 } 215 }
216 } 216 }
217 break; 217 break;
218 case "texturecommit": 218 case "texturecommit":
219 sendRegionHandshakeToAll(); 219 sendRegionHandshakeToAll();
220 break; 220 break;
221 case "setregionterrain": 221 case "setregionterrain":
222 if (packet.ParamList.Length != 9) 222 if (packet.ParamList.Length != 9)
223 { 223 {
224 MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); 224 MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
225 } 225 }
226 else 226 else
227 { 227 {
228 m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); 228 m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
229 m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); 229 m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
230 m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); 230 m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
231 m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter); 231 m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
232 m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); 232 m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
233 233
234 sendRegionInfoPacketToAll(); 234 sendRegionInfoPacketToAll();
235 } 235 }
236 break; 236 break;
237 default: 237 default:
238 MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString()); 238 MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
239 break; 239 break;
240 } 240 }
241 } 241 }
242 } 242 }
243 243
244 public void sendRegionInfoPacketToAll() 244 public void sendRegionInfoPacketToAll()
245 { 245 {
246 List<Avatar> avatars = m_world.RequestAvatarList(); 246 List<Avatar> avatars = m_world.RequestAvatarList();
247 247
248 for (int i = 0; i < avatars.Count; i++) 248 for (int i = 0; i < avatars.Count; i++)
249 { 249 {
250 this.sendRegionInfoPacket(avatars[i].ControllingClient); 250 this.sendRegionInfoPacket(avatars[i].ControllingClient);
251 } 251 }
252 } 252 }
253 253
254 public void sendRegionHandshakeToAll() 254 public void sendRegionHandshakeToAll()
255 { 255 {
256 List<Avatar> avatars = m_world.RequestAvatarList(); 256 List<Avatar> avatars = m_world.RequestAvatarList();
257 257
258 for (int i = 0; i < avatars.Count; i++) 258 for (int i = 0; i < avatars.Count; i++)
259 { 259 {
260 this.sendRegionHandshake(avatars[i].ControllingClient); 260 this.sendRegionHandshake(avatars[i].ControllingClient);
261 } 261 }
262 } 262 }
263 263
264 public void sendRegionInfoPacket(IClientAPI remote_client) 264 public void sendRegionInfoPacket(IClientAPI remote_client)
265 { 265 {
266 Encoding _enc = Encoding.ASCII; 266 Encoding _enc = Encoding.ASCII;
267 267
268 AgentCircuitData circuitData = remote_client.RequestClientInfo(); 268 AgentCircuitData circuitData = remote_client.RequestClientInfo();
269 269
270 RegionInfoPacket regionInfoPacket = new RegionInfoPacket(); 270 RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
271 regionInfoPacket.AgentData.AgentID = circuitData.AgentID; 271 regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
272 regionInfoPacket.AgentData.SessionID = circuitData.SessionID; 272 regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
273 regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor; 273 regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor;
274 regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID; 274 regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID;
275 regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents; 275 regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents;
276 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor; 276 regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor;
277 regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID; 277 regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID;
278 regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter; 278 regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter;
279 regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX; 279 regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX;
280 regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; 280 regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY;
281 regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; 281 regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags;
282 regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; 282 regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess;
283 regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); 283 regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName);
284 regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; 284 regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour;
285 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; 285 regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit;
286 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; 286 regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit;
287 regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun; 287 regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun;
288 regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight; 288 regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight;
289 289
290 remote_client.OutPacket(regionInfoPacket); 290 remote_client.OutPacket(regionInfoPacket);
291 } 291 }
292 292
293 public void sendRegionHandshake(IClientAPI remoteClient) 293 public void sendRegionHandshake(IClientAPI remoteClient)
294 { 294 {
295 remoteClient.SendRegionHandshake(m_regInfo); 295 remoteClient.SendRegionHandshake(m_regInfo);
296 } 296 }
297 297
298 } 298 }
299} 299}
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index c068866..6ee57a5 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -1,63 +1,63 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using libsecondlife; 29using libsecondlife;
30 30
31using OpenSim.Framework.Types; 31using OpenSim.Framework.Types;
32using OpenSim.Region; 32using OpenSim.Region;
33using OpenSim.Region.Environment; 33using OpenSim.Region.Environment;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35 35
36using System.Collections.Generic; 36using System.Collections.Generic;
37 37
38namespace OpenSim.Region.Interfaces 38namespace OpenSim.Region.Interfaces
39{ 39{
40 public interface IRegionDataStore 40 public interface IRegionDataStore
41 { 41 {
42 /// <summary> 42 /// <summary>
43 /// Initialises the data storage engine 43 /// Initialises the data storage engine
44 /// </summary> 44 /// </summary>
45 /// <param name="filename">The file to save the database to (may not be applicable)</param> 45 /// <param name="filename">The file to save the database to (may not be applicable)</param>
46 /// <param name="dbname">The name of the database to store to (may not be applicable)</param> 46 /// <param name="dbname">The name of the database to store to (may not be applicable)</param>
47 void Initialise(string filename, string dbname); 47 void Initialise(string filename, string dbname);
48 48
49 void StoreObject(SceneObject obj); 49 void StoreObject(SceneObject obj);
50 void RemoveObject(LLUUID uuid); 50 void RemoveObject(LLUUID uuid);
51 51
52 List<SceneObject> LoadObjects(); 52 List<SceneObject> LoadObjects();
53 53
54 void StoreTerrain(double[,] terrain); 54 void StoreTerrain(double[,] terrain);
55 double[,] LoadTerrain(); 55 double[,] LoadTerrain();
56 56
57 void StoreParcel(OpenSim.Region.Environment.Parcel Parcel); 57 void StoreParcel(OpenSim.Region.Environment.Parcel Parcel);
58 void RemoveParcel(uint ID); 58 void RemoveParcel(uint ID);
59 List<OpenSim.Region.Environment.Parcel> LoadParcels(); 59 List<OpenSim.Region.Environment.Parcel> LoadParcels();
60 60
61 void Shutdown(); 61 void Shutdown();
62 } 62 }
63} \ No newline at end of file 63} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs
index 31b9b1d..fbff556 100644
--- a/OpenSim/Region/Environment/ParcelManager.cs
+++ b/OpenSim/Region/Environment/ParcelManager.cs
@@ -1,1206 +1,1206 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; 35using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
36using System.IO; 36using System.IO;
37 37
38namespace OpenSim.Region.Environment 38namespace OpenSim.Region.Environment
39{ 39{
40 40
41 41
42 #region ParcelManager Class 42 #region ParcelManager Class
43 /// <summary> 43 /// <summary>
44 /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc) 44 /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc)
45 /// </summary> 45 /// </summary>
46 public class ParcelManager : ILocalStorageParcelReceiver 46 public class ParcelManager : ILocalStorageParcelReceiver
47 { 47 {
48 48
49 #region Constants 49 #region Constants
50 //Parcel types set with flags in ParcelOverlay. 50 //Parcel types set with flags in ParcelOverlay.
51 //Only one of these can be used. 51 //Only one of these can be used.
52 public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000 52 public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000
53 public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 53 public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001
54 public const byte PARCEL_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 54 public const byte PARCEL_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010
55 public const byte PARCEL_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 55 public const byte PARCEL_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
56 public const byte PARCEL_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 56 public const byte PARCEL_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
57 public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 57 public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
58 58
59 59
60 //Flags that when set, a border on the given side will be placed 60 //Flags that when set, a border on the given side will be placed
61 //NOTE: North and East is assumable by the west and south sides (if parcel to east has a west border, then I have an east border; etc) 61 //NOTE: North and East is assumable by the west and south sides (if parcel to east has a west border, then I have an east border; etc)
62 //This took forever to figure out -- jeesh. /blame LL for even having to send these 62 //This took forever to figure out -- jeesh. /blame LL for even having to send these
63 public const byte PARCEL_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 63 public const byte PARCEL_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
64 public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 64 public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
65 65
66 //RequestResults (I think these are right, they seem to work): 66 //RequestResults (I think these are right, they seem to work):
67 public const int PARCEL_RESULT_ONE_PARCEL = 0; // The request they made contained only one parcel 67 public const int PARCEL_RESULT_ONE_PARCEL = 0; // The request they made contained only one parcel
68 public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel 68 public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel
69 69
70 //ParcelSelectObjects 70 //ParcelSelectObjects
71 public const int PARCEL_SELECT_OBJECTS_OWNER = 2; 71 public const int PARCEL_SELECT_OBJECTS_OWNER = 2;
72 public const int PARCEL_SELECT_OBJECTS_GROUP = 4; 72 public const int PARCEL_SELECT_OBJECTS_GROUP = 4;
73 public const int PARCEL_SELECT_OBJECTS_OTHER = 8; 73 public const int PARCEL_SELECT_OBJECTS_OTHER = 8;
74 74
75 75
76 //These are other constants. Yay! 76 //These are other constants. Yay!
77 public const int START_PARCEL_LOCAL_ID = 1; 77 public const int START_PARCEL_LOCAL_ID = 1;
78 #endregion 78 #endregion
79 79
80 #region Member Variables 80 #region Member Variables
81 public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>(); 81 public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>();
82 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; 82 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
83 private int[,] parcelIDList = new int[64, 64]; 83 private int[,] parcelIDList = new int[64, 64];
84 84
85 /// <summary> 85 /// <summary>
86 /// Set to true when a prim is moved, created, added. Performs a prim count update 86 /// Set to true when a prim is moved, created, added. Performs a prim count update
87 /// </summary> 87 /// </summary>
88 public bool parcelPrimCountTainted = false; 88 public bool parcelPrimCountTainted = false;
89 89
90 private Scene m_world; 90 private Scene m_world;
91 private RegionInfo m_regInfo; 91 private RegionInfo m_regInfo;
92 92
93 #endregion 93 #endregion
94 94
95 #region Constructors 95 #region Constructors
96 public ParcelManager(Scene world, RegionInfo reginfo) 96 public ParcelManager(Scene world, RegionInfo reginfo)
97 { 97 {
98 98
99 m_world = world; 99 m_world = world;
100 m_regInfo = reginfo; 100 m_regInfo = reginfo;
101 parcelIDList.Initialize(); 101 parcelIDList.Initialize();
102 102
103 } 103 }
104 #endregion 104 #endregion
105 105
106 #region Member Functions 106 #region Member Functions
107 107
108 #region Parcel From Storage Functions 108 #region Parcel From Storage Functions
109 public void ParcelFromStorage(ParcelData data) 109 public void ParcelFromStorage(ParcelData data)
110 { 110 {
111 Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world); 111 Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world);
112 new_parcel.parcelData = data.Copy(); 112 new_parcel.parcelData = data.Copy();
113 new_parcel.setParcelBitmapFromByteArray(); 113 new_parcel.setParcelBitmapFromByteArray();
114 addParcel(new_parcel); 114 addParcel(new_parcel);
115 115
116 } 116 }
117 117
118 public void NoParcelDataFromStorage() 118 public void NoParcelDataFromStorage()
119 { 119 {
120 resetSimParcels(); 120 resetSimParcels();
121 } 121 }
122 #endregion 122 #endregion
123 123
124 #region Parcel Add/Remove/Get/Create 124 #region Parcel Add/Remove/Get/Create
125 /// <summary> 125 /// <summary>
126 /// Creates a basic Parcel object without an owner (a zeroed key) 126 /// Creates a basic Parcel object without an owner (a zeroed key)
127 /// </summary> 127 /// </summary>
128 /// <returns></returns> 128 /// <returns></returns>
129 public Parcel createBaseParcel() 129 public Parcel createBaseParcel()
130 { 130 {
131 return new Parcel(new LLUUID(), false, m_world); 131 return new Parcel(new LLUUID(), false, m_world);
132 } 132 }
133 133
134 /// <summary> 134 /// <summary>
135 /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own 135 /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own
136 /// </summary> 136 /// </summary>
137 /// <param name="new_parcel">The parcel being added</param> 137 /// <param name="new_parcel">The parcel being added</param>
138 public Parcel addParcel(Parcel new_parcel) 138 public Parcel addParcel(Parcel new_parcel)
139 { 139 {
140 lastParcelLocalID++; 140 lastParcelLocalID++;
141 new_parcel.parcelData.localID = lastParcelLocalID; 141 new_parcel.parcelData.localID = lastParcelLocalID;
142 parcelList.Add(lastParcelLocalID, new_parcel.Copy()); 142 parcelList.Add(lastParcelLocalID, new_parcel.Copy());
143 143
144 144
145 bool[,] parcelBitmap = new_parcel.getParcelBitmap(); 145 bool[,] parcelBitmap = new_parcel.getParcelBitmap();
146 int x, y; 146 int x, y;
147 for (x = 0; x < 64; x++) 147 for (x = 0; x < 64; x++)
148 { 148 {
149 for (y = 0; y < 64; y++) 149 for (y = 0; y < 64; y++)
150 { 150 {
151 if (parcelBitmap[x, y]) 151 if (parcelBitmap[x, y])
152 { 152 {
153 parcelIDList[x, y] = lastParcelLocalID; 153 parcelIDList[x, y] = lastParcelLocalID;
154 } 154 }
155 } 155 }
156 } 156 }
157 parcelList[lastParcelLocalID].forceUpdateParcelInfo(); 157 parcelList[lastParcelLocalID].forceUpdateParcelInfo();
158 158
159 return new_parcel; 159 return new_parcel;
160 160
161 } 161 }
162 /// <summary> 162 /// <summary>
163 /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList 163 /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList
164 /// </summary> 164 /// </summary>
165 /// <param name="local_id">Parcel.localID of the parcel to remove.</param> 165 /// <param name="local_id">Parcel.localID of the parcel to remove.</param>
166 public void removeParcel(int local_id) 166 public void removeParcel(int local_id)
167 { 167 {
168 int x, y; 168 int x, y;
169 for (x = 0; x < 64; x++) 169 for (x = 0; x < 64; x++)
170 { 170 {
171 for (y = 0; y < 64; y++) 171 for (y = 0; y < 64; y++)
172 { 172 {
173 if (parcelIDList[x, y] == local_id) 173 if (parcelIDList[x, y] == local_id)
174 { 174 {
175 throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y); 175 throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y);
176 } 176 }
177 } 177 }
178 } 178 }
179 m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData); 179 m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData);
180 parcelList.Remove(local_id); 180 parcelList.Remove(local_id);
181 } 181 }
182 182
183 private void performFinalParcelJoin(Parcel master, Parcel slave) 183 private void performFinalParcelJoin(Parcel master, Parcel slave)
184 { 184 {
185 int x, y; 185 int x, y;
186 bool[,] parcelBitmapSlave = slave.getParcelBitmap(); 186 bool[,] parcelBitmapSlave = slave.getParcelBitmap();
187 for (x = 0; x < 64; x++) 187 for (x = 0; x < 64; x++)
188 { 188 {
189 for (y = 0; y < 64; y++) 189 for (y = 0; y < 64; y++)
190 { 190 {
191 if (parcelBitmapSlave[x, y]) 191 if (parcelBitmapSlave[x, y])
192 { 192 {
193 parcelIDList[x, y] = master.parcelData.localID; 193 parcelIDList[x, y] = master.parcelData.localID;
194 } 194 }
195 } 195 }
196 } 196 }
197 removeParcel(slave.parcelData.localID); 197 removeParcel(slave.parcelData.localID);
198 } 198 }
199 /// <summary> 199 /// <summary>
200 /// Get the parcel at the specified point 200 /// Get the parcel at the specified point
201 /// </summary> 201 /// </summary>
202 /// <param name="x">Value between 0 - 256 on the x axis of the point</param> 202 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
203 /// <param name="y">Value between 0 - 256 on the y axis of the point</param> 203 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
204 /// <returns>Parcel at the point supplied</returns> 204 /// <returns>Parcel at the point supplied</returns>
205 public Parcel getParcel(float x_float, float y_float) 205 public Parcel getParcel(float x_float, float y_float)
206 { 206 {
207 int x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x_float) / Convert.ToDecimal(4.0))); 207 int x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x_float) / Convert.ToDecimal(4.0)));
208 int y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y_float) / Convert.ToDecimal(4.0))); 208 int y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y_float) / Convert.ToDecimal(4.0)));
209 209
210 if (x > 63 || y > 63 || x < 0 || y < 0) 210 if (x > 63 || y > 63 || x < 0 || y < 0)
211 { 211 {
212 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 212 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
213 } 213 }
214 else 214 else
215 { 215 {
216 // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); 216 // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")");
217 return parcelList[parcelIDList[x, y]]; 217 return parcelList[parcelIDList[x, y]];
218 } 218 }
219 } 219 }
220 220
221 public Parcel getParcel(int x, int y) 221 public Parcel getParcel(int x, int y)
222 { 222 {
223 if (x > 256 || y > 256 || x < 0 || y < 0) 223 if (x > 256 || y > 256 || x < 0 || y < 0)
224 { 224 {
225 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 225 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
226 } 226 }
227 else 227 else
228 { 228 {
229 return parcelList[parcelIDList[x / 4, y / 4]]; 229 return parcelList[parcelIDList[x / 4, y / 4]];
230 } 230 }
231 } 231 }
232 #endregion 232 #endregion
233 233
234 #region Parcel Modification 234 #region Parcel Modification
235 /// <summary> 235 /// <summary>
236 /// Subdivides a parcel 236 /// Subdivides a parcel
237 /// </summary> 237 /// </summary>
238 /// <param name="start_x">West Point</param> 238 /// <param name="start_x">West Point</param>
239 /// <param name="start_y">South Point</param> 239 /// <param name="start_y">South Point</param>
240 /// <param name="end_x">East Point</param> 240 /// <param name="end_x">East Point</param>
241 /// <param name="end_y">North Point</param> 241 /// <param name="end_y">North Point</param>
242 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> 242 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param>
243 /// <returns>Returns true if successful</returns> 243 /// <returns>Returns true if successful</returns>
244 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 244 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
245 { 245 {
246 246
247 //First, lets loop through the points and make sure they are all in the same parcel 247 //First, lets loop through the points and make sure they are all in the same parcel
248 //Get the parcel at start 248 //Get the parcel at start
249 Parcel startParcel = getParcel(start_x, start_y); 249 Parcel startParcel = getParcel(start_x, start_y);
250 if (startParcel == null) return false; //No such parcel at the beginning 250 if (startParcel == null) return false; //No such parcel at the beginning
251 251
252 //Loop through the points 252 //Loop through the points
253 try 253 try
254 { 254 {
255 int totalX = end_x - start_x; 255 int totalX = end_x - start_x;
256 int totalY = end_y - start_y; 256 int totalY = end_y - start_y;
257 int x, y; 257 int x, y;
258 for (y = 0; y < totalY; y++) 258 for (y = 0; y < totalY; y++)
259 { 259 {
260 for (x = 0; x < totalX; x++) 260 for (x = 0; x < totalX; x++)
261 { 261 {
262 Parcel tempParcel = getParcel(start_x + x, start_y + y); 262 Parcel tempParcel = getParcel(start_x + x, start_y + y);
263 if (tempParcel == null) return false; //No such parcel at that point 263 if (tempParcel == null) return false; //No such parcel at that point
264 if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no 264 if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no
265 } 265 }
266 } 266 }
267 } 267 }
268 catch (Exception) 268 catch (Exception)
269 { 269 {
270 return false; //Exception. For now, lets skip subdivision 270 return false; //Exception. For now, lets skip subdivision
271 } 271 }
272 272
273 //If we are still here, then they are subdividing within one parcel 273 //If we are still here, then they are subdividing within one parcel
274 //Check owner 274 //Check owner
275 if (startParcel.parcelData.ownerID != attempting_user_id) 275 if (startParcel.parcelData.ownerID != attempting_user_id)
276 { 276 {
277 return false; //They cant do this! 277 return false; //They cant do this!
278 } 278 }
279 279
280 //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info) 280 //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info)
281 Parcel newParcel = startParcel.Copy(); 281 Parcel newParcel = startParcel.Copy();
282 newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName; 282 newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName;
283 newParcel.parcelData.globalID = LLUUID.Random(); 283 newParcel.parcelData.globalID = LLUUID.Random();
284 284
285 newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y)); 285 newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y));
286 286
287 //Now, lets set the subdivision area of the original to false 287 //Now, lets set the subdivision area of the original to false
288 int startParcelIndex = startParcel.parcelData.localID; 288 int startParcelIndex = startParcel.parcelData.localID;
289 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); 289 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false));
290 parcelList[startParcelIndex].forceUpdateParcelInfo(); 290 parcelList[startParcelIndex].forceUpdateParcelInfo();
291 291
292 292
293 this.setPrimsTainted(); 293 this.setPrimsTainted();
294 294
295 //Now add the new parcel 295 //Now add the new parcel
296 Parcel result = addParcel(newParcel); 296 Parcel result = addParcel(newParcel);
297 result.sendParcelUpdateToAvatarsOverMe(); 297 result.sendParcelUpdateToAvatarsOverMe();
298 298
299 299
300 300
301 301
302 return true; 302 return true;
303 } 303 }
304 /// <summary> 304 /// <summary>
305 /// Join 2 parcels together 305 /// Join 2 parcels together
306 /// </summary> 306 /// </summary>
307 /// <param name="start_x">x value in first parcel</param> 307 /// <param name="start_x">x value in first parcel</param>
308 /// <param name="start_y">y value in first parcel</param> 308 /// <param name="start_y">y value in first parcel</param>
309 /// <param name="end_x">x value in second parcel</param> 309 /// <param name="end_x">x value in second parcel</param>
310 /// <param name="end_y">y value in second parcel</param> 310 /// <param name="end_y">y value in second parcel</param>
311 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param> 311 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param>
312 /// <returns>Returns true if successful</returns> 312 /// <returns>Returns true if successful</returns>
313 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 313 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
314 { 314 {
315 end_x -= 4; 315 end_x -= 4;
316 end_y -= 4; 316 end_y -= 4;
317 317
318 List<Parcel> selectedParcels = new List<Parcel>(); 318 List<Parcel> selectedParcels = new List<Parcel>();
319 int stepXSelected = 0; 319 int stepXSelected = 0;
320 int stepYSelected = 0; 320 int stepYSelected = 0;
321 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) 321 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
322 { 322 {
323 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) 323 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
324 { 324 {
325 Parcel p = getParcel(stepXSelected,stepYSelected); 325 Parcel p = getParcel(stepXSelected,stepYSelected);
326 if (!selectedParcels.Contains(p)) 326 if (!selectedParcels.Contains(p))
327 { 327 {
328 selectedParcels.Add(p); 328 selectedParcels.Add(p);
329 } 329 }
330 } 330 }
331 } 331 }
332 Parcel masterParcel = selectedParcels[0]; 332 Parcel masterParcel = selectedParcels[0];
333 selectedParcels.RemoveAt(0); 333 selectedParcels.RemoveAt(0);
334 334
335 335
336 if (selectedParcels.Count < 1) 336 if (selectedParcels.Count < 1)
337 { 337 {
338 return false; //Only one parcel selected 338 return false; //Only one parcel selected
339 } 339 }
340 if (masterParcel.parcelData.ownerID != attempting_user_id) 340 if (masterParcel.parcelData.ownerID != attempting_user_id)
341 { 341 {
342 return false; //Not the same owner 342 return false; //Not the same owner
343 } 343 }
344 foreach (Parcel p in selectedParcels) 344 foreach (Parcel p in selectedParcels)
345 { 345 {
346 if (p.parcelData.ownerID != masterParcel.parcelData.ownerID) 346 if (p.parcelData.ownerID != masterParcel.parcelData.ownerID)
347 { 347 {
348 return false; //Over multiple users. TODO: make this just ignore this parcel? 348 return false; //Over multiple users. TODO: make this just ignore this parcel?
349 } 349 }
350 } 350 }
351 foreach (Parcel slaveParcel in selectedParcels) 351 foreach (Parcel slaveParcel in selectedParcels)
352 { 352 {
353 parcelList[masterParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(masterParcel.getParcelBitmap(), slaveParcel.getParcelBitmap())); 353 parcelList[masterParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(masterParcel.getParcelBitmap(), slaveParcel.getParcelBitmap()));
354 performFinalParcelJoin(masterParcel, slaveParcel); 354 performFinalParcelJoin(masterParcel, slaveParcel);
355 } 355 }
356 356
357 357
358 this.setPrimsTainted(); 358 this.setPrimsTainted();
359 359
360 masterParcel.sendParcelUpdateToAvatarsOverMe(); 360 masterParcel.sendParcelUpdateToAvatarsOverMe();
361 361
362 return true; 362 return true;
363 363
364 364
365 365
366 } 366 }
367 #endregion 367 #endregion
368 368
369 #region Parcel Updating 369 #region Parcel Updating
370 /// <summary> 370 /// <summary>
371 /// Where we send the ParcelOverlay packet to the client 371 /// Where we send the ParcelOverlay packet to the client
372 /// </summary> 372 /// </summary>
373 /// <param name="remote_client">The object representing the client</param> 373 /// <param name="remote_client">The object representing the client</param>
374 public void sendParcelOverlay(IClientAPI remote_client) 374 public void sendParcelOverlay(IClientAPI remote_client)
375 { 375 {
376 const int PARCEL_BLOCKS_PER_PACKET = 1024; 376 const int PARCEL_BLOCKS_PER_PACKET = 1024;
377 int x, y = 0; 377 int x, y = 0;
378 byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; 378 byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
379 int byteArrayCount = 0; 379 int byteArrayCount = 0;
380 int sequenceID = 0; 380 int sequenceID = 0;
381 ParcelOverlayPacket packet; 381 ParcelOverlayPacket packet;
382 382
383 for (y = 0; y < 64; y++) 383 for (y = 0; y < 64; y++)
384 { 384 {
385 for (x = 0; x < 64; x++) 385 for (x = 0; x < 64; x++)
386 { 386 {
387 byte tempByte = (byte)0; //This represents the byte for the current 4x4 387 byte tempByte = (byte)0; //This represents the byte for the current 4x4
388 Parcel currentParcelBlock = getParcel(x * 4, y * 4); 388 Parcel currentParcelBlock = getParcel(x * 4, y * 4);
389 389
390 if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId) 390 if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId)
391 { 391 {
392 //Owner Flag 392 //Owner Flag
393 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER); 393 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER);
394 } 394 }
395 else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId)) 395 else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId))
396 { 396 {
397 //Sale Flag 397 //Sale Flag
398 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE); 398 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE);
399 } 399 }
400 else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero) 400 else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero)
401 { 401 {
402 //Public Flag 402 //Public Flag
403 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC); 403 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC);
404 } 404 }
405 else 405 else
406 { 406 {
407 //Other Flag 407 //Other Flag
408 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER); 408 tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER);
409 } 409 }
410 410
411 411
412 //Now for border control 412 //Now for border control
413 if (x == 0) 413 if (x == 0)
414 { 414 {
415 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); 415 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
416 } 416 }
417 else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock) 417 else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock)
418 { 418 {
419 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); 419 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST);
420 } 420 }
421 421
422 if (y == 0) 422 if (y == 0)
423 { 423 {
424 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); 424 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
425 } 425 }
426 else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock) 426 else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock)
427 { 427 {
428 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); 428 tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH);
429 } 429 }
430 430
431 byteArray[byteArrayCount] = tempByte; 431 byteArray[byteArrayCount] = tempByte;
432 byteArrayCount++; 432 byteArrayCount++;
433 if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET) 433 if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET)
434 { 434 {
435 byteArrayCount = 0; 435 byteArrayCount = 0;
436 packet = new ParcelOverlayPacket(); 436 packet = new ParcelOverlayPacket();
437 packet.ParcelData.Data = byteArray; 437 packet.ParcelData.Data = byteArray;
438 packet.ParcelData.SequenceID = sequenceID; 438 packet.ParcelData.SequenceID = sequenceID;
439 remote_client.OutPacket((Packet)packet); 439 remote_client.OutPacket((Packet)packet);
440 sequenceID++; 440 sequenceID++;
441 byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; 441 byteArray = new byte[PARCEL_BLOCKS_PER_PACKET];
442 } 442 }
443 } 443 }
444 } 444 }
445 445
446 446
447 } 447 }
448 448
449 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client) 449 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client)
450 { 450 {
451 //Get the parcels within the bounds 451 //Get the parcels within the bounds
452 List<Parcel> temp = new List<Parcel>(); 452 List<Parcel> temp = new List<Parcel>();
453 int x, y, i; 453 int x, y, i;
454 int inc_x = end_x - start_x; 454 int inc_x = end_x - start_x;
455 int inc_y = end_y - start_y; 455 int inc_y = end_y - start_y;
456 for (x = 0; x < inc_x; x++) 456 for (x = 0; x < inc_x; x++)
457 { 457 {
458 for (y = 0; y < inc_y; y++) 458 for (y = 0; y < inc_y; y++)
459 { 459 {
460 Parcel currentParcel = getParcel(start_x + x, start_y + y); 460 Parcel currentParcel = getParcel(start_x + x, start_y + y);
461 if (!temp.Contains(currentParcel)) 461 if (!temp.Contains(currentParcel))
462 { 462 {
463 currentParcel.forceUpdateParcelInfo(); 463 currentParcel.forceUpdateParcelInfo();
464 temp.Add(currentParcel); 464 temp.Add(currentParcel);
465 } 465 }
466 } 466 }
467 } 467 }
468 468
469 int requestResult = PARCEL_RESULT_ONE_PARCEL; 469 int requestResult = PARCEL_RESULT_ONE_PARCEL;
470 if (temp.Count > 1) 470 if (temp.Count > 1)
471 { 471 {
472 requestResult = PARCEL_RESULT_MULTIPLE_PARCELS; 472 requestResult = PARCEL_RESULT_MULTIPLE_PARCELS;
473 } 473 }
474 474
475 for (i = 0; i < temp.Count; i++) 475 for (i = 0; i < temp.Count; i++)
476 { 476 {
477 temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client); 477 temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client);
478 } 478 }
479 479
480 480
481 sendParcelOverlay(remote_client); 481 sendParcelOverlay(remote_client);
482 } 482 }
483 483
484 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 484 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
485 { 485 {
486 if (parcelList.ContainsKey(packet.ParcelData.LocalID)) 486 if (parcelList.ContainsKey(packet.ParcelData.LocalID))
487 { 487 {
488 parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client); 488 parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client);
489 } 489 }
490 } 490 }
491 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) 491 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
492 { 492 {
493 subdivide(west, south, east, north, remote_client.AgentId); 493 subdivide(west, south, east, north, remote_client.AgentId);
494 } 494 }
495 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) 495 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
496 { 496 {
497 join(west, south, east, north, remote_client.AgentId); 497 join(west, south, east, north, remote_client.AgentId);
498 498
499 } 499 }
500 500
501 public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) 501 public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client)
502 { 502 {
503 parcelList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); 503 parcelList[local_id].sendForceObjectSelect(local_id, request_type, remote_client);
504 } 504 }
505 505
506 public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) 506 public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client)
507 { 507 {
508 parcelList[local_id].sendParcelObjectOwners(remote_client); 508 parcelList[local_id].sendParcelObjectOwners(remote_client);
509 } 509 }
510 #endregion 510 #endregion
511 511
512 /// <summary> 512 /// <summary>
513 /// Resets the sim to the default parcel (full sim parcel owned by the default user) 513 /// Resets the sim to the default parcel (full sim parcel owned by the default user)
514 /// </summary> 514 /// </summary>
515 public void resetSimParcels() 515 public void resetSimParcels()
516 { 516 {
517 //Remove all the parcels in the sim and add a blank, full sim parcel set to public 517 //Remove all the parcels in the sim and add a blank, full sim parcel set to public
518 parcelList.Clear(); 518 parcelList.Clear();
519 lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; 519 lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
520 parcelIDList.Initialize(); 520 parcelIDList.Initialize();
521 521
522 Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world); 522 Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world);
523 523
524 fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256)); 524 fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256));
525 fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID; 525 fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID;
526 526
527 addParcel(fullSimParcel); 527 addParcel(fullSimParcel);
528 528
529 } 529 }
530 530
531 531
532 public void handleSignificantClientMovement(IClientAPI remote_client) 532 public void handleSignificantClientMovement(IClientAPI remote_client)
533 { 533 {
534 Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); 534 Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId);
535 if (clientAvatar != null) 535 if (clientAvatar != null)
536 { 536 {
537 Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y); 537 Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y);
538 if (over != null) 538 if (over != null)
539 { 539 {
540 over.sendParcelProperties(0, false, 0, remote_client); 540 over.sendParcelProperties(0, false, 0, remote_client);
541 } 541 }
542 } 542 }
543 } 543 }
544 544
545 public void resetAllParcelPrimCounts() 545 public void resetAllParcelPrimCounts()
546 { 546 {
547 foreach (Parcel p in parcelList.Values) 547 foreach (Parcel p in parcelList.Values)
548 { 548 {
549 p.resetParcelPrimCounts(); 549 p.resetParcelPrimCounts();
550 } 550 }
551 } 551 }
552 public void setPrimsTainted() 552 public void setPrimsTainted()
553 { 553 {
554 this.parcelPrimCountTainted = true; 554 this.parcelPrimCountTainted = true;
555 } 555 }
556 556
557 public void addPrimToParcelCounts(SceneObject obj) 557 public void addPrimToParcelCounts(SceneObject obj)
558 { 558 {
559 LLVector3 position = obj.Pos; 559 LLVector3 position = obj.Pos;
560 Parcel parcelUnderPrim = getParcel(position.X, position.Y); 560 Parcel parcelUnderPrim = getParcel(position.X, position.Y);
561 if (parcelUnderPrim != null) 561 if (parcelUnderPrim != null)
562 { 562 {
563 parcelUnderPrim.addPrimToCount(obj); 563 parcelUnderPrim.addPrimToCount(obj);
564 } 564 }
565 } 565 }
566 566
567 public void removePrimFromParcelCounts(SceneObject obj) 567 public void removePrimFromParcelCounts(SceneObject obj)
568 { 568 {
569 foreach (Parcel p in parcelList.Values) 569 foreach (Parcel p in parcelList.Values)
570 { 570 {
571 p.removePrimFromCount(obj); 571 p.removePrimFromCount(obj);
572 } 572 }
573 } 573 }
574 574
575 public void finalizeParcelPrimCountUpdate() 575 public void finalizeParcelPrimCountUpdate()
576 { 576 {
577 //Get Simwide prim count for owner 577 //Get Simwide prim count for owner
578 Dictionary<LLUUID, List<Parcel>> parcelOwnersAndParcels = new Dictionary<LLUUID,List<Parcel>>(); 578 Dictionary<LLUUID, List<Parcel>> parcelOwnersAndParcels = new Dictionary<LLUUID,List<Parcel>>();
579 foreach (Parcel p in parcelList.Values) 579 foreach (Parcel p in parcelList.Values)
580 { 580 {
581 if(!parcelOwnersAndParcels.ContainsKey(p.parcelData.ownerID)) 581 if(!parcelOwnersAndParcels.ContainsKey(p.parcelData.ownerID))
582 { 582 {
583 List<Parcel> tempList = new List<Parcel>(); 583 List<Parcel> tempList = new List<Parcel>();
584 tempList.Add(p); 584 tempList.Add(p);
585 parcelOwnersAndParcels.Add(p.parcelData.ownerID,tempList); 585 parcelOwnersAndParcels.Add(p.parcelData.ownerID,tempList);
586 } 586 }
587 else 587 else
588 { 588 {
589 parcelOwnersAndParcels[p.parcelData.ownerID].Add(p); 589 parcelOwnersAndParcels[p.parcelData.ownerID].Add(p);
590 } 590 }
591 } 591 }
592 592
593 foreach (LLUUID owner in parcelOwnersAndParcels.Keys) 593 foreach (LLUUID owner in parcelOwnersAndParcels.Keys)
594 { 594 {
595 int simArea = 0; 595 int simArea = 0;
596 int simPrims = 0; 596 int simPrims = 0;
597 foreach (Parcel p in parcelOwnersAndParcels[owner]) 597 foreach (Parcel p in parcelOwnersAndParcels[owner])
598 { 598 {
599 simArea += p.parcelData.area; 599 simArea += p.parcelData.area;
600 simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims + p.parcelData.selectedPrims; 600 simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims + p.parcelData.selectedPrims;
601 } 601 }
602 602
603 foreach (Parcel p in parcelOwnersAndParcels[owner]) 603 foreach (Parcel p in parcelOwnersAndParcels[owner])
604 { 604 {
605 p.parcelData.simwideArea = simArea; 605 p.parcelData.simwideArea = simArea;
606 p.parcelData.simwidePrims = simPrims; 606 p.parcelData.simwidePrims = simPrims;
607 } 607 }
608 } 608 }
609 609
610 } 610 }
611 #endregion 611 #endregion
612 } 612 }
613 #endregion 613 #endregion
614 614
615 615
616 #region Parcel Class 616 #region Parcel Class
617 /// <summary> 617 /// <summary>
618 /// Keeps track of a specific parcel's information 618 /// Keeps track of a specific parcel's information
619 /// </summary> 619 /// </summary>
620 public class Parcel 620 public class Parcel
621 { 621 {
622 #region Member Variables 622 #region Member Variables
623 public ParcelData parcelData = new ParcelData(); 623 public ParcelData parcelData = new ParcelData();
624 public List<SceneObject> primsOverMe = new List<SceneObject>(); 624 public List<SceneObject> primsOverMe = new List<SceneObject>();
625 625
626 public Scene m_world; 626 public Scene m_world;
627 627
628 private bool[,] parcelBitmap = new bool[64, 64]; 628 private bool[,] parcelBitmap = new bool[64, 64];
629 629
630 #endregion 630 #endregion
631 631
632 632
633 #region Constructors 633 #region Constructors
634 public Parcel(LLUUID owner_id, bool is_group_owned, Scene world) 634 public Parcel(LLUUID owner_id, bool is_group_owned, Scene world)
635 { 635 {
636 m_world = world; 636 m_world = world;
637 parcelData.ownerID = owner_id; 637 parcelData.ownerID = owner_id;
638 parcelData.isGroupOwned = is_group_owned; 638 parcelData.isGroupOwned = is_group_owned;
639 639
640 } 640 }
641 #endregion 641 #endregion
642 642
643 643
644 #region Member Functions 644 #region Member Functions
645 645
646 #region General Functions 646 #region General Functions
647 /// <summary> 647 /// <summary>
648 /// Checks to see if this parcel contains a point 648 /// Checks to see if this parcel contains a point
649 /// </summary> 649 /// </summary>
650 /// <param name="x"></param> 650 /// <param name="x"></param>
651 /// <param name="y"></param> 651 /// <param name="y"></param>
652 /// <returns>Returns true if the parcel contains the specified point</returns> 652 /// <returns>Returns true if the parcel contains the specified point</returns>
653 public bool containsPoint(int x, int y) 653 public bool containsPoint(int x, int y)
654 { 654 {
655 if (x >= 0 && y >= 0 && x <= 256 && x <= 256) 655 if (x >= 0 && y >= 0 && x <= 256 && x <= 256)
656 { 656 {
657 return (parcelBitmap[x / 4, y / 4] == true); 657 return (parcelBitmap[x / 4, y / 4] == true);
658 } 658 }
659 else 659 else
660 { 660 {
661 return false; 661 return false;
662 } 662 }
663 } 663 }
664 664
665 public Parcel Copy() 665 public Parcel Copy()
666 { 666 {
667 Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world); 667 Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world);
668 668
669 //Place all new variables here! 669 //Place all new variables here!
670 newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone()); 670 newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone());
671 newParcel.parcelData = parcelData.Copy(); 671 newParcel.parcelData = parcelData.Copy();
672 672
673 return newParcel; 673 return newParcel;
674 } 674 }
675 675
676 #endregion 676 #endregion
677 677
678 678
679 #region Packet Request Handling 679 #region Packet Request Handling
680 /// <summary> 680 /// <summary>
681 /// Sends parcel properties as requested 681 /// Sends parcel properties as requested
682 /// </summary> 682 /// </summary>
683 /// <param name="sequence_id">ID sent by client for them to keep track of</param> 683 /// <param name="sequence_id">ID sent by client for them to keep track of</param>
684 /// <param name="snap_selection">Bool sent by client for them to use</param> 684 /// <param name="snap_selection">Bool sent by client for them to use</param>
685 /// <param name="remote_client">Object representing the client</param> 685 /// <param name="remote_client">Object representing the client</param>
686 public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) 686 public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
687 { 687 {
688 688
689 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); 689 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket();
690 updatePacket.ParcelData.AABBMax = parcelData.AABBMax; 690 updatePacket.ParcelData.AABBMax = parcelData.AABBMax;
691 updatePacket.ParcelData.AABBMin = parcelData.AABBMin; 691 updatePacket.ParcelData.AABBMin = parcelData.AABBMin;
692 updatePacket.ParcelData.Area = parcelData.area; 692 updatePacket.ParcelData.Area = parcelData.area;
693 updatePacket.ParcelData.AuctionID = parcelData.auctionID; 693 updatePacket.ParcelData.AuctionID = parcelData.auctionID;
694 updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented 694 updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented
695 695
696 updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray; 696 updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray;
697 697
698 updatePacket.ParcelData.Desc = Helpers.StringToField(parcelData.parcelDesc); 698 updatePacket.ParcelData.Desc = Helpers.StringToField(parcelData.parcelDesc);
699 updatePacket.ParcelData.Category = (byte)parcelData.category; 699 updatePacket.ParcelData.Category = (byte)parcelData.category;
700 updatePacket.ParcelData.ClaimDate = parcelData.claimDate; 700 updatePacket.ParcelData.ClaimDate = parcelData.claimDate;
701 updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice; 701 updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice;
702 updatePacket.ParcelData.GroupID = parcelData.groupID; 702 updatePacket.ParcelData.GroupID = parcelData.groupID;
703 updatePacket.ParcelData.GroupPrims = parcelData.groupPrims; 703 updatePacket.ParcelData.GroupPrims = parcelData.groupPrims;
704 updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned; 704 updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned;
705 updatePacket.ParcelData.LandingType = (byte)parcelData.landingType; 705 updatePacket.ParcelData.LandingType = (byte)parcelData.landingType;
706 updatePacket.ParcelData.LocalID = parcelData.localID; 706 updatePacket.ParcelData.LocalID = parcelData.localID;
707 if (parcelData.area > 0) 707 if (parcelData.area > 0)
708 { 708 {
709 updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); 709 updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor)));
710 } 710 }
711 else 711 else
712 { 712 {
713 updatePacket.ParcelData.MaxPrims = 0; 713 updatePacket.ParcelData.MaxPrims = 0;
714 } 714 }
715 updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale; 715 updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale;
716 updatePacket.ParcelData.MediaID = parcelData.mediaID; 716 updatePacket.ParcelData.MediaID = parcelData.mediaID;
717 updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL); 717 updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL);
718 updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL); 718 updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL);
719 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); 719 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName);
720 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented 720 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
721 updatePacket.ParcelData.OtherCount = 0; //unemplemented 721 updatePacket.ParcelData.OtherCount = 0; //unemplemented
722 updatePacket.ParcelData.OtherPrims = parcelData.otherPrims; 722 updatePacket.ParcelData.OtherPrims = parcelData.otherPrims;
723 updatePacket.ParcelData.OwnerID = parcelData.ownerID; 723 updatePacket.ParcelData.OwnerID = parcelData.ownerID;
724 updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims; 724 updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims;
725 updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; 725 updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags;
726 updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; 726 updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor;
727 updatePacket.ParcelData.PassHours = parcelData.passHours; 727 updatePacket.ParcelData.PassHours = parcelData.passHours;
728 updatePacket.ParcelData.PassPrice = parcelData.passPrice; 728 updatePacket.ParcelData.PassPrice = parcelData.passPrice;
729 updatePacket.ParcelData.PublicCount = 0; //unemplemented 729 updatePacket.ParcelData.PublicCount = 0; //unemplemented
730 updatePacket.ParcelData.RegionDenyAnonymous = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0); 730 updatePacket.ParcelData.RegionDenyAnonymous = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0);
731 updatePacket.ParcelData.RegionDenyIdentified = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0); 731 updatePacket.ParcelData.RegionDenyIdentified = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0);
732 updatePacket.ParcelData.RegionDenyTransacted = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0); 732 updatePacket.ParcelData.RegionDenyTransacted = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0);
733 updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); 733 updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0);
734 updatePacket.ParcelData.RentPrice = 0; 734 updatePacket.ParcelData.RentPrice = 0;
735 updatePacket.ParcelData.RequestResult = request_result; 735 updatePacket.ParcelData.RequestResult = request_result;
736 updatePacket.ParcelData.SalePrice = parcelData.salePrice; 736 updatePacket.ParcelData.SalePrice = parcelData.salePrice;
737 updatePacket.ParcelData.SelectedPrims = parcelData.selectedPrims; 737 updatePacket.ParcelData.SelectedPrims = parcelData.selectedPrims;
738 updatePacket.ParcelData.SelfCount = 0;//unemplemented 738 updatePacket.ParcelData.SelfCount = 0;//unemplemented
739 updatePacket.ParcelData.SequenceID = sequence_id; 739 updatePacket.ParcelData.SequenceID = sequence_id;
740 if (parcelData.simwideArea > 0) 740 if (parcelData.simwideArea > 0)
741 { 741 {
742 updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); 742 updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor)));
743 } 743 }
744 else 744 else
745 { 745 {
746 updatePacket.ParcelData.SimWideMaxPrims = 0; 746 updatePacket.ParcelData.SimWideMaxPrims = 0;
747 } 747 }
748 updatePacket.ParcelData.SimWideTotalPrims = parcelData.simwidePrims; 748 updatePacket.ParcelData.SimWideTotalPrims = parcelData.simwidePrims;
749 updatePacket.ParcelData.SnapSelection = snap_selection; 749 updatePacket.ParcelData.SnapSelection = snap_selection;
750 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; 750 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID;
751 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; 751 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus;
752 updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims + parcelData.selectedPrims; 752 updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims + parcelData.selectedPrims;
753 updatePacket.ParcelData.UserLocation = parcelData.userLocation; 753 updatePacket.ParcelData.UserLocation = parcelData.userLocation;
754 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; 754 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt;
755 remote_client.OutPacket((Packet)updatePacket); 755 remote_client.OutPacket((Packet)updatePacket);
756 } 756 }
757 757
758 public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 758 public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
759 { 759 {
760 if (remote_client.AgentId == parcelData.ownerID) 760 if (remote_client.AgentId == parcelData.ownerID)
761 { 761 {
762 //Needs later group support 762 //Needs later group support
763 parcelData.authBuyerID = packet.ParcelData.AuthBuyerID; 763 parcelData.authBuyerID = packet.ParcelData.AuthBuyerID;
764 parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; 764 parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category;
765 parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); 765 parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
766 parcelData.groupID = packet.ParcelData.GroupID; 766 parcelData.groupID = packet.ParcelData.GroupID;
767 parcelData.landingType = packet.ParcelData.LandingType; 767 parcelData.landingType = packet.ParcelData.LandingType;
768 parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale; 768 parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
769 parcelData.mediaID = packet.ParcelData.MediaID; 769 parcelData.mediaID = packet.ParcelData.MediaID;
770 parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); 770 parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
771 parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); 771 parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
772 parcelData.parcelName = Helpers.FieldToUTF8String(packet.ParcelData.Name); 772 parcelData.parcelName = Helpers.FieldToUTF8String(packet.ParcelData.Name);
773 parcelData.parcelFlags = packet.ParcelData.ParcelFlags; 773 parcelData.parcelFlags = packet.ParcelData.ParcelFlags;
774 parcelData.passHours = packet.ParcelData.PassHours; 774 parcelData.passHours = packet.ParcelData.PassHours;
775 parcelData.passPrice = packet.ParcelData.PassPrice; 775 parcelData.passPrice = packet.ParcelData.PassPrice;
776 parcelData.salePrice = packet.ParcelData.SalePrice; 776 parcelData.salePrice = packet.ParcelData.SalePrice;
777 parcelData.snapshotID = packet.ParcelData.SnapshotID; 777 parcelData.snapshotID = packet.ParcelData.SnapshotID;
778 parcelData.userLocation = packet.ParcelData.UserLocation; 778 parcelData.userLocation = packet.ParcelData.UserLocation;
779 parcelData.userLookAt = packet.ParcelData.UserLookAt; 779 parcelData.userLookAt = packet.ParcelData.UserLookAt;
780 sendParcelUpdateToAvatarsOverMe(); 780 sendParcelUpdateToAvatarsOverMe();
781 781
782 782
783 } 783 }
784 } 784 }
785 785
786 public void sendParcelUpdateToAvatarsOverMe() 786 public void sendParcelUpdateToAvatarsOverMe()
787 { 787 {
788 List<Avatar> avatars = m_world.RequestAvatarList(); 788 List<Avatar> avatars = m_world.RequestAvatarList();
789 for (int i = 0; i < avatars.Count; i++) 789 for (int i = 0; i < avatars.Count; i++)
790 { 790 {
791 Parcel over = m_world.ParcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y)); 791 Parcel over = m_world.ParcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y));
792 if (over.parcelData.localID == this.parcelData.localID) 792 if (over.parcelData.localID == this.parcelData.localID)
793 { 793 {
794 sendParcelProperties(0, false, 0, avatars[i].ControllingClient); 794 sendParcelProperties(0, false, 0, avatars[i].ControllingClient);
795 } 795 }
796 } 796 }
797 } 797 }
798 #endregion 798 #endregion
799 799
800 800
801 #region Update Functions 801 #region Update Functions
802 /// <summary> 802 /// <summary>
803 /// Updates the AABBMin and AABBMax values after area/shape modification of parcel 803 /// Updates the AABBMin and AABBMax values after area/shape modification of parcel
804 /// </summary> 804 /// </summary>
805 private void updateAABBAndAreaValues() 805 private void updateAABBAndAreaValues()
806 { 806 {
807 int min_x = 64; 807 int min_x = 64;
808 int min_y = 64; 808 int min_y = 64;
809 int max_x = 0; 809 int max_x = 0;
810 int max_y = 0; 810 int max_y = 0;
811 int tempArea = 0; 811 int tempArea = 0;
812 int x, y; 812 int x, y;
813 for (x = 0; x < 64; x++) 813 for (x = 0; x < 64; x++)
814 { 814 {
815 for (y = 0; y < 64; y++) 815 for (y = 0; y < 64; y++)
816 { 816 {
817 if (parcelBitmap[x, y] == true) 817 if (parcelBitmap[x, y] == true)
818 { 818 {
819 if (min_x > x) min_x = x; 819 if (min_x > x) min_x = x;
820 if (min_y > y) min_y = y; 820 if (min_y > y) min_y = y;
821 if (max_x < x) max_x = x; 821 if (max_x < x) max_x = x;
822 if (max_y < y) max_y = y; 822 if (max_y < y) max_y = y;
823 tempArea += 16; //16sqm parcel 823 tempArea += 16; //16sqm parcel
824 } 824 }
825 } 825 }
826 } 826 }
827 parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4))); 827 parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4)));
828 parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4))); 828 parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4)));
829 parcelData.area = tempArea; 829 parcelData.area = tempArea;
830 } 830 }
831 831
832 public void updateParcelBitmapByteArray() 832 public void updateParcelBitmapByteArray()
833 { 833 {
834 parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes(); 834 parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes();
835 } 835 }
836 836
837 /// <summary> 837 /// <summary>
838 /// Update all settings in parcel such as area, bitmap byte array, etc 838 /// Update all settings in parcel such as area, bitmap byte array, etc
839 /// </summary> 839 /// </summary>
840 public void forceUpdateParcelInfo() 840 public void forceUpdateParcelInfo()
841 { 841 {
842 this.updateAABBAndAreaValues(); 842 this.updateAABBAndAreaValues();
843 this.updateParcelBitmapByteArray(); 843 this.updateParcelBitmapByteArray();
844 } 844 }
845 845
846 public void setParcelBitmapFromByteArray() 846 public void setParcelBitmapFromByteArray()
847 { 847 {
848 parcelBitmap = convertBytesToParcelBitmap(); 848 parcelBitmap = convertBytesToParcelBitmap();
849 } 849 }
850 #endregion 850 #endregion
851 851
852 852
853 #region Parcel Bitmap Functions 853 #region Parcel Bitmap Functions
854 /// <summary> 854 /// <summary>
855 /// Sets the parcel's bitmap manually 855 /// Sets the parcel's bitmap manually
856 /// </summary> 856 /// </summary>
857 /// <param name="bitmap">64x64 block representing where this parcel is on a map</param> 857 /// <param name="bitmap">64x64 block representing where this parcel is on a map</param>
858 public void setParcelBitmap(bool[,] bitmap) 858 public void setParcelBitmap(bool[,] bitmap)
859 { 859 {
860 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) 860 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
861 { 861 {
862 //Throw an exception - The bitmap is not 64x64 862 //Throw an exception - The bitmap is not 64x64
863 throw new Exception("Error: Invalid Parcel Bitmap"); 863 throw new Exception("Error: Invalid Parcel Bitmap");
864 } 864 }
865 else 865 else
866 { 866 {
867 //Valid: Lets set it 867 //Valid: Lets set it
868 parcelBitmap = bitmap; 868 parcelBitmap = bitmap;
869 forceUpdateParcelInfo(); 869 forceUpdateParcelInfo();
870 870
871 } 871 }
872 } 872 }
873 /// <summary> 873 /// <summary>
874 /// Gets the parcels bitmap manually 874 /// Gets the parcels bitmap manually
875 /// </summary> 875 /// </summary>
876 /// <returns></returns> 876 /// <returns></returns>
877 public bool[,] getParcelBitmap() 877 public bool[,] getParcelBitmap()
878 { 878 {
879 return parcelBitmap; 879 return parcelBitmap;
880 } 880 }
881 /// <summary> 881 /// <summary>
882 /// Converts the parcel bitmap to a packet friendly byte array 882 /// Converts the parcel bitmap to a packet friendly byte array
883 /// </summary> 883 /// </summary>
884 /// <returns></returns> 884 /// <returns></returns>
885 private byte[] convertParcelBitmapToBytes() 885 private byte[] convertParcelBitmapToBytes()
886 { 886 {
887 byte[] tempConvertArr = new byte[512]; 887 byte[] tempConvertArr = new byte[512];
888 byte tempByte = 0; 888 byte tempByte = 0;
889 int x, y, i, byteNum = 0; 889 int x, y, i, byteNum = 0;
890 i = 0; 890 i = 0;
891 for (y = 0; y < 64; y++) 891 for (y = 0; y < 64; y++)
892 { 892 {
893 for (x = 0; x < 64; x++) 893 for (x = 0; x < 64; x++)
894 { 894 {
895 tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8)); 895 tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8));
896 if (i % 8 == 0) 896 if (i % 8 == 0)
897 { 897 {
898 tempConvertArr[byteNum] = tempByte; 898 tempConvertArr[byteNum] = tempByte;
899 tempByte = (byte)0; 899 tempByte = (byte)0;
900 i = 0; 900 i = 0;
901 byteNum++; 901 byteNum++;
902 } 902 }
903 } 903 }
904 } 904 }
905 return tempConvertArr; 905 return tempConvertArr;
906 } 906 }
907 907
908 private bool[,] convertBytesToParcelBitmap() 908 private bool[,] convertBytesToParcelBitmap()
909 { 909 {
910 bool[,] tempConvertMap = new bool[64, 64]; 910 bool[,] tempConvertMap = new bool[64, 64];
911 tempConvertMap.Initialize(); 911 tempConvertMap.Initialize();
912 byte tempByte = 0; 912 byte tempByte = 0;
913 int x = 0, y = 0, i = 0, bitNum = 0; 913 int x = 0, y = 0, i = 0, bitNum = 0;
914 for (i = 0; i < 512; i++) 914 for (i = 0; i < 512; i++)
915 { 915 {
916 tempByte = parcelData.parcelBitmapByteArray[i]; 916 tempByte = parcelData.parcelBitmapByteArray[i];
917 for (bitNum = 0; bitNum < 8; bitNum++) 917 for (bitNum = 0; bitNum < 8; bitNum++)
918 { 918 {
919 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); 919 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1);
920 tempConvertMap[x, y] = bit; 920 tempConvertMap[x, y] = bit;
921 x++; 921 x++;
922 if (x > 63) 922 if (x > 63)
923 { 923 {
924 x = 0; 924 x = 0;
925 y++; 925 y++;
926 } 926 }
927 927
928 } 928 }
929 929
930 } 930 }
931 return tempConvertMap; 931 return tempConvertMap;
932 } 932 }
933 /// <summary> 933 /// <summary>
934 /// Full sim parcel creation 934 /// Full sim parcel creation
935 /// </summary> 935 /// </summary>
936 /// <returns></returns> 936 /// <returns></returns>
937 public static bool[,] basicFullRegionParcelBitmap() 937 public static bool[,] basicFullRegionParcelBitmap()
938 { 938 {
939 return getSquareParcelBitmap(0, 0, 256, 256); 939 return getSquareParcelBitmap(0, 0, 256, 256);
940 } 940 }
941 941
942 /// <summary> 942 /// <summary>
943 /// Used to modify the bitmap between the x and y points. Points use 64 scale 943 /// Used to modify the bitmap between the x and y points. Points use 64 scale
944 /// </summary> 944 /// </summary>
945 /// <param name="start_x"></param> 945 /// <param name="start_x"></param>
946 /// <param name="start_y"></param> 946 /// <param name="start_y"></param>
947 /// <param name="end_x"></param> 947 /// <param name="end_x"></param>
948 /// <param name="end_y"></param> 948 /// <param name="end_y"></param>
949 /// <returns></returns> 949 /// <returns></returns>
950 public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y) 950 public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y)
951 { 951 {
952 952
953 bool[,] tempBitmap = new bool[64, 64]; 953 bool[,] tempBitmap = new bool[64, 64];
954 tempBitmap.Initialize(); 954 tempBitmap.Initialize();
955 955
956 tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); 956 tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
957 return tempBitmap; 957 return tempBitmap;
958 } 958 }
959 959
960 /// <summary> 960 /// <summary>
961 /// Change a parcel's bitmap at within a square and set those points to a specific value 961 /// Change a parcel's bitmap at within a square and set those points to a specific value
962 /// </summary> 962 /// </summary>
963 /// <param name="parcel_bitmap"></param> 963 /// <param name="parcel_bitmap"></param>
964 /// <param name="start_x"></param> 964 /// <param name="start_x"></param>
965 /// <param name="start_y"></param> 965 /// <param name="start_y"></param>
966 /// <param name="end_x"></param> 966 /// <param name="end_x"></param>
967 /// <param name="end_y"></param> 967 /// <param name="end_y"></param>
968 /// <param name="set_value"></param> 968 /// <param name="set_value"></param>
969 /// <returns></returns> 969 /// <returns></returns>
970 public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) 970 public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value)
971 { 971 {
972 if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2) 972 if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2)
973 { 973 {
974 //Throw an exception - The bitmap is not 64x64 974 //Throw an exception - The bitmap is not 64x64
975 throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()"); 975 throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()");
976 } 976 }
977 977
978 int x, y; 978 int x, y;
979 for (y = 0; y < 64; y++) 979 for (y = 0; y < 64; y++)
980 { 980 {
981 for (x = 0; x < 64; x++) 981 for (x = 0; x < 64; x++)
982 { 982 {
983 if (x >= start_x / 4 && x < end_x / 4 983 if (x >= start_x / 4 && x < end_x / 4
984 && y >= start_y / 4 && y < end_y / 4) 984 && y >= start_y / 4 && y < end_y / 4)
985 { 985 {
986 parcel_bitmap[x, y] = set_value; 986 parcel_bitmap[x, y] = set_value;
987 } 987 }
988 } 988 }
989 } 989 }
990 return parcel_bitmap; 990 return parcel_bitmap;
991 } 991 }
992 /// <summary> 992 /// <summary>
993 /// Join the true values of 2 bitmaps together 993 /// Join the true values of 2 bitmaps together
994 /// </summary> 994 /// </summary>
995 /// <param name="bitmap_base"></param> 995 /// <param name="bitmap_base"></param>
996 /// <param name="bitmap_add"></param> 996 /// <param name="bitmap_add"></param>
997 /// <returns></returns> 997 /// <returns></returns>
998 public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) 998 public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
999 { 999 {
1000 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) 1000 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
1001 { 1001 {
1002 //Throw an exception - The bitmap is not 64x64 1002 //Throw an exception - The bitmap is not 64x64
1003 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps"); 1003 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps");
1004 } 1004 }
1005 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) 1005 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
1006 { 1006 {
1007 //Throw an exception - The bitmap is not 64x64 1007 //Throw an exception - The bitmap is not 64x64
1008 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps"); 1008 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps");
1009 1009
1010 } 1010 }
1011 1011
1012 int x, y; 1012 int x, y;
1013 for (y = 0; y < 64; y++) 1013 for (y = 0; y < 64; y++)
1014 { 1014 {
1015 for (x = 0; x < 64; x++) 1015 for (x = 0; x < 64; x++)
1016 { 1016 {
1017 if (bitmap_add[x, y]) 1017 if (bitmap_add[x, y])
1018 { 1018 {
1019 bitmap_base[x, y] = true; 1019 bitmap_base[x, y] = true;
1020 } 1020 }
1021 } 1021 }
1022 } 1022 }
1023 return bitmap_base; 1023 return bitmap_base;
1024 } 1024 }
1025 #endregion 1025 #endregion
1026 1026
1027 #region Object Select and Object Owner Listing 1027 #region Object Select and Object Owner Listing
1028 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) 1028 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client)
1029 { 1029 {
1030 List<uint> resultLocalIDs = new List<uint>(); 1030 List<uint> resultLocalIDs = new List<uint>();
1031 foreach (SceneObject obj in primsOverMe) 1031 foreach (SceneObject obj in primsOverMe)
1032 { 1032 {
1033 if (obj.rootLocalID > 0) 1033 if (obj.rootLocalID > 0)
1034 { 1034 {
1035 if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.parcelData.ownerID) 1035 if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.parcelData.ownerID)
1036 { 1036 {
1037 resultLocalIDs.Add(obj.rootLocalID); 1037 resultLocalIDs.Add(obj.rootLocalID);
1038 } 1038 }
1039 else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! 1039 else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support!
1040 { 1040 {
1041 1041
1042 } 1042 }
1043 else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId) 1043 else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId)
1044 { 1044 {
1045 resultLocalIDs.Add(obj.rootLocalID); 1045 resultLocalIDs.Add(obj.rootLocalID);
1046 } 1046 }
1047 } 1047 }
1048 } 1048 }
1049 1049
1050 1050
1051 bool firstCall = true; 1051 bool firstCall = true;
1052 int MAX_OBJECTS_PER_PACKET = 251; 1052 int MAX_OBJECTS_PER_PACKET = 251;
1053 ForceObjectSelectPacket pack = new ForceObjectSelectPacket(); 1053 ForceObjectSelectPacket pack = new ForceObjectSelectPacket();
1054 ForceObjectSelectPacket.DataBlock[] data; 1054 ForceObjectSelectPacket.DataBlock[] data;
1055 while (resultLocalIDs.Count > 0) 1055 while (resultLocalIDs.Count > 0)
1056 { 1056 {
1057 if (firstCall) 1057 if (firstCall)
1058 { 1058 {
1059 pack._Header.ResetList = true; 1059 pack._Header.ResetList = true;
1060 firstCall = false; 1060 firstCall = false;
1061 } 1061 }
1062 else 1062 else
1063 { 1063 {
1064 pack._Header.ResetList = false; 1064 pack._Header.ResetList = false;
1065 } 1065 }
1066 1066
1067 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) 1067 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET)
1068 { 1068 {
1069 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; 1069 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
1070 } 1070 }
1071 else 1071 else
1072 { 1072 {
1073 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; 1073 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count];
1074 } 1074 }
1075 1075
1076 int i; 1076 int i;
1077 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) 1077 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++)
1078 { 1078 {
1079 data[i] = new ForceObjectSelectPacket.DataBlock(); 1079 data[i] = new ForceObjectSelectPacket.DataBlock();
1080 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); 1080 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]);
1081 resultLocalIDs.RemoveAt(0); 1081 resultLocalIDs.RemoveAt(0);
1082 } 1082 }
1083 pack.Data = data; 1083 pack.Data = data;
1084 remote_client.OutPacket((Packet)pack); 1084 remote_client.OutPacket((Packet)pack);
1085 } 1085 }
1086 1086
1087 } 1087 }
1088 public void sendParcelObjectOwners(IClientAPI remote_client) 1088 public void sendParcelObjectOwners(IClientAPI remote_client)
1089 { 1089 {
1090 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID,int>(); 1090 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID,int>();
1091 foreach(SceneObject obj in primsOverMe) 1091 foreach(SceneObject obj in primsOverMe)
1092 { 1092 {
1093 if(!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) 1093 if(!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID))
1094 { 1094 {
1095 ownersAndCount.Add(obj.rootPrimitive.OwnerID,0); 1095 ownersAndCount.Add(obj.rootPrimitive.OwnerID,0);
1096 } 1096 }
1097 ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; 1097 ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount;
1098 } 1098 }
1099 if (ownersAndCount.Count > 0) 1099 if (ownersAndCount.Count > 0)
1100 { 1100 {
1101 1101
1102 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; 1102 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32];
1103 1103
1104 if(ownersAndCount.Count < 32) 1104 if(ownersAndCount.Count < 32)
1105 { 1105 {
1106 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; 1106 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count];
1107 } 1107 }
1108 1108
1109 1109
1110 int num = 0; 1110 int num = 0;
1111 foreach (LLUUID owner in ownersAndCount.Keys) 1111 foreach (LLUUID owner in ownersAndCount.Keys)
1112 { 1112 {
1113 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); 1113 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
1114 dataBlock[num].Count = ownersAndCount[owner]; 1114 dataBlock[num].Count = ownersAndCount[owner];
1115 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added 1115 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added
1116 dataBlock[num].OnlineStatus = true; //TODO: fix me later 1116 dataBlock[num].OnlineStatus = true; //TODO: fix me later
1117 dataBlock[num].OwnerID = owner; 1117 dataBlock[num].OwnerID = owner;
1118 1118
1119 num++; 1119 num++;
1120 } 1120 }
1121 1121
1122 ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket(); 1122 ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket();
1123 pack.Data = dataBlock; 1123 pack.Data = dataBlock;
1124 remote_client.OutPacket(pack); 1124 remote_client.OutPacket(pack);
1125 } 1125 }
1126 } 1126 }
1127 #endregion 1127 #endregion
1128 1128
1129 #region Object Returning 1129 #region Object Returning
1130 public void returnObject(SceneObject obj) 1130 public void returnObject(SceneObject obj)
1131 { 1131 {
1132 } 1132 }
1133 public void returnParcelObjects(int type, LLUUID owner) 1133 public void returnParcelObjects(int type, LLUUID owner)
1134 { 1134 {
1135 1135
1136 } 1136 }
1137 #endregion 1137 #endregion
1138 1138
1139 #region Object Adding/Removing from Parcel 1139 #region Object Adding/Removing from Parcel
1140 public void resetParcelPrimCounts() 1140 public void resetParcelPrimCounts()
1141 { 1141 {
1142 parcelData.groupPrims = 0; 1142 parcelData.groupPrims = 0;
1143 parcelData.ownerPrims = 0; 1143 parcelData.ownerPrims = 0;
1144 parcelData.otherPrims = 0; 1144 parcelData.otherPrims = 0;
1145 parcelData.selectedPrims = 0; 1145 parcelData.selectedPrims = 0;
1146 primsOverMe.Clear(); 1146 primsOverMe.Clear();
1147 } 1147 }
1148 1148
1149 public void addPrimToCount(SceneObject obj) 1149 public void addPrimToCount(SceneObject obj)
1150 { 1150 {
1151 LLUUID prim_owner = obj.rootPrimitive.OwnerID; 1151 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
1152 int prim_count = obj.primCount; 1152 int prim_count = obj.primCount;
1153 1153
1154 if (obj.isSelected) 1154 if (obj.isSelected)
1155 { 1155 {
1156 parcelData.selectedPrims += prim_count; 1156 parcelData.selectedPrims += prim_count;
1157 } 1157 }
1158 else 1158 else
1159 { 1159 {
1160 if (prim_owner == parcelData.ownerID) 1160 if (prim_owner == parcelData.ownerID)
1161 { 1161 {
1162 parcelData.ownerPrims += prim_count; 1162 parcelData.ownerPrims += prim_count;
1163 } 1163 }
1164 else 1164 else
1165 { 1165 {
1166 parcelData.otherPrims += prim_count; 1166 parcelData.otherPrims += prim_count;
1167 } 1167 }
1168 } 1168 }
1169 1169
1170 primsOverMe.Add(obj); 1170 primsOverMe.Add(obj);
1171 1171
1172 } 1172 }
1173 1173
1174 public void removePrimFromCount(SceneObject obj) 1174 public void removePrimFromCount(SceneObject obj)
1175 { 1175 {
1176 if (primsOverMe.Contains(obj)) 1176 if (primsOverMe.Contains(obj))
1177 { 1177 {
1178 LLUUID prim_owner = obj.rootPrimitive.OwnerID; 1178 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
1179 int prim_count = obj.primCount; 1179 int prim_count = obj.primCount;
1180 1180
1181 if (prim_owner == parcelData.ownerID) 1181 if (prim_owner == parcelData.ownerID)
1182 { 1182 {
1183 parcelData.ownerPrims -= prim_count; 1183 parcelData.ownerPrims -= prim_count;
1184 } 1184 }
1185 else if (prim_owner == parcelData.groupID) 1185 else if (prim_owner == parcelData.groupID)
1186 { 1186 {
1187 parcelData.groupPrims -= prim_count; 1187 parcelData.groupPrims -= prim_count;
1188 } 1188 }
1189 else 1189 else
1190 { 1190 {
1191 parcelData.otherPrims -= prim_count; 1191 parcelData.otherPrims -= prim_count;
1192 } 1192 }
1193 1193
1194 primsOverMe.Remove(obj); 1194 primsOverMe.Remove(obj);
1195 } 1195 }
1196 } 1196 }
1197 #endregion 1197 #endregion
1198 1198
1199 #endregion 1199 #endregion
1200 1200
1201 1201
1202 } 1202 }
1203 #endregion 1203 #endregion
1204 1204
1205 1205
1206} 1206}
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs
index cd67e97..35fbf45 100644
--- a/OpenSim/Region/Environment/RegionManager.cs
+++ b/OpenSim/Region/Environment/RegionManager.cs
@@ -1,29 +1,29 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using OpenSim.Framework; 2using OpenSim.Framework;
3using OpenSim.Framework.Communications; 3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Servers; 4using OpenSim.Framework.Servers;
5using OpenSim.Region.Capabilities; 5using OpenSim.Region.Capabilities;
6using OpenSim.Region.Environment.Scenes; 6using OpenSim.Region.Environment.Scenes;
7 7
8namespace OpenSim.Region.Environment 8namespace OpenSim.Region.Environment
9{ 9{
10 public class RegionManager //needs renaming , but first we need to rename the namespace 10 public class RegionManager //needs renaming , but first we need to rename the namespace
11 { 11 {
12 protected AuthenticateSessionsBase authenticateHandler; 12 protected AuthenticateSessionsBase authenticateHandler;
13 protected RegionCommsListener regionCommsHost; 13 protected RegionCommsListener regionCommsHost;
14 protected CommunicationsManager commsManager; 14 protected CommunicationsManager commsManager;
15 protected List<Caps> capsHandlers = new List<Caps>(); 15 protected List<Caps> capsHandlers = new List<Caps>();
16 protected BaseHttpServer httpListener; 16 protected BaseHttpServer httpListener;
17 17
18 protected Scene m_Scene; 18 protected Scene m_Scene;
19 19
20 public ParcelManager parcelManager; 20 public ParcelManager parcelManager;
21 public EstateManager estateManager; 21 public EstateManager estateManager;
22 22
23 public RegionManager() 23 public RegionManager()
24 { 24 {
25 25
26 } 26 }
27 27
28 } 28 }
29} 29}
diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs
index 084c9ab..2456a4e 100644
--- a/OpenSim/Region/Environment/Scenes/Entity.cs
+++ b/OpenSim/Region/Environment/Scenes/Entity.cs
@@ -1,115 +1,115 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Physics.Manager; 30using OpenSim.Physics.Manager;
31 31
32namespace OpenSim.Region.Environment.Scenes 32namespace OpenSim.Region.Environment.Scenes
33{ 33{
34 public abstract class Entity :EntityBase //this class (Entity) will be phased out 34 public abstract class Entity :EntityBase //this class (Entity) will be phased out
35 { 35 {
36 protected PhysicsActor _physActor; 36 protected PhysicsActor _physActor;
37 37
38 /// <summary> 38 /// <summary>
39 /// 39 ///
40 /// </summary> 40 /// </summary>
41 public override LLVector3 Pos 41 public override LLVector3 Pos
42 { 42 {
43 get 43 get
44 { 44 {
45 if (this._physActor != null) 45 if (this._physActor != null)
46 { 46 {
47 m_pos.X = _physActor.Position.X; 47 m_pos.X = _physActor.Position.X;
48 m_pos.Y = _physActor.Position.Y; 48 m_pos.Y = _physActor.Position.Y;
49 m_pos.Z = _physActor.Position.Z; 49 m_pos.Z = _physActor.Position.Z;
50 } 50 }
51 51
52 return m_pos; 52 return m_pos;
53 } 53 }
54 set 54 set
55 { 55 {
56 if (this._physActor != null) 56 if (this._physActor != null)
57 { 57 {
58 try 58 try
59 { 59 {
60 lock (this.m_world.SyncRoot) 60 lock (this.m_world.SyncRoot)
61 { 61 {
62 62
63 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 63 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
64 } 64 }
65 } 65 }
66 catch (Exception e) 66 catch (Exception e)
67 { 67 {
68 Console.WriteLine(e.Message); 68 Console.WriteLine(e.Message);
69 } 69 }
70 } 70 }
71 71
72 m_pos = value; 72 m_pos = value;
73 } 73 }
74 } 74 }
75 75
76 76
77 /// <summary> 77 /// <summary>
78 /// 78 ///
79 /// </summary> 79 /// </summary>
80 public override LLVector3 Velocity 80 public override LLVector3 Velocity
81 { 81 {
82 get 82 get
83 { 83 {
84 if (this._physActor != null) 84 if (this._physActor != null)
85 { 85 {
86 m_velocity.X = _physActor.Velocity.X; 86 m_velocity.X = _physActor.Velocity.X;
87 m_velocity.Y = _physActor.Velocity.Y; 87 m_velocity.Y = _physActor.Velocity.Y;
88 m_velocity.Z = _physActor.Velocity.Z; 88 m_velocity.Z = _physActor.Velocity.Z;
89 } 89 }
90 90
91 return m_velocity; 91 return m_velocity;
92 } 92 }
93 set 93 set
94 { 94 {
95 if (this._physActor != null) 95 if (this._physActor != null)
96 { 96 {
97 try 97 try
98 { 98 {
99 lock (this.m_world.SyncRoot) 99 lock (this.m_world.SyncRoot)
100 { 100 {
101 101
102 this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); 102 this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
103 } 103 }
104 } 104 }
105 catch (Exception e) 105 catch (Exception e)
106 { 106 {
107 Console.WriteLine(e.Message); 107 Console.WriteLine(e.Message);
108 } 108 }
109 } 109 }
110 110
111 m_velocity = value; 111 m_velocity = value;
112 } 112 }
113 } 113 }
114 } 114 }
115} 115}
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
index 65a0395..04cf595 100644
--- a/OpenSim/Region/Environment/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -1,142 +1,142 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using Axiom.Math; 2using Axiom.Math;
3using libsecondlife; 3using libsecondlife;
4 4
5namespace OpenSim.Region.Environment.Scenes 5namespace OpenSim.Region.Environment.Scenes
6{ 6{
7 public abstract class EntityBase 7 public abstract class EntityBase
8 { 8 {
9 public LLUUID uuid; 9 public LLUUID uuid;
10 10
11 protected List<EntityBase> children; 11 protected List<EntityBase> children;
12 12
13 protected Scene m_world; 13 protected Scene m_world;
14 protected string m_name; 14 protected string m_name;
15 15
16 /// <summary> 16 /// <summary>
17 /// 17 ///
18 /// </summary> 18 /// </summary>
19 public virtual string Name 19 public virtual string Name
20 { 20 {
21 get { return m_name; } 21 get { return m_name; }
22 set { m_name = value; } 22 set { m_name = value; }
23 } 23 }
24 24
25 protected LLVector3 m_pos; 25 protected LLVector3 m_pos;
26 /// <summary> 26 /// <summary>
27 /// 27 ///
28 /// </summary> 28 /// </summary>
29 public virtual LLVector3 Pos 29 public virtual LLVector3 Pos
30 { 30 {
31 get 31 get
32 { 32 {
33 return m_pos; 33 return m_pos;
34 } 34 }
35 set 35 set
36 { 36 {
37 m_pos = value; 37 m_pos = value;
38 } 38 }
39 } 39 }
40 40
41 public LLVector3 m_velocity; 41 public LLVector3 m_velocity;
42 42
43 /// <summary> 43 /// <summary>
44 /// 44 ///
45 /// </summary> 45 /// </summary>
46 public virtual LLVector3 Velocity 46 public virtual LLVector3 Velocity
47 { 47 {
48 get 48 get
49 { 49 {
50 return m_velocity; 50 return m_velocity;
51 } 51 }
52 set 52 set
53 { 53 {
54 m_velocity = value; 54 m_velocity = value;
55 } 55 }
56 } 56 }
57 57
58 protected Quaternion m_rotation = new Quaternion(0,0,1,0); 58 protected Quaternion m_rotation = new Quaternion(0,0,1,0);
59 59
60 public virtual Quaternion Rotation 60 public virtual Quaternion Rotation
61 { 61 {
62 get 62 get
63 { 63 {
64 return m_rotation; 64 return m_rotation;
65 } 65 }
66 set 66 set
67 { 67 {
68 m_rotation = value; 68 m_rotation = value;
69 } 69 }
70 } 70 }
71 71
72 protected uint m_localId; 72 protected uint m_localId;
73 73
74 public uint LocalId 74 public uint LocalId
75 { 75 {
76 get { return m_localId; } 76 get { return m_localId; }
77 set { m_localId = value; } 77 set { m_localId = value; }
78 } 78 }
79 79
80 /// <summary> 80 /// <summary>
81 /// Creates a new Entity (should not occur on it's own) 81 /// Creates a new Entity (should not occur on it's own)
82 /// </summary> 82 /// </summary>
83 public EntityBase() 83 public EntityBase()
84 { 84 {
85 uuid = new LLUUID(); 85 uuid = new LLUUID();
86 86
87 m_pos = new LLVector3(); 87 m_pos = new LLVector3();
88 m_velocity = new LLVector3(); 88 m_velocity = new LLVector3();
89 Rotation = new Quaternion(); 89 Rotation = new Quaternion();
90 m_name = "(basic entity)"; 90 m_name = "(basic entity)";
91 children = new List<EntityBase>(); 91 children = new List<EntityBase>();
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
95 /// 95 ///
96 /// </summary> 96 /// </summary>
97 public virtual void updateMovement() 97 public virtual void updateMovement()
98 { 98 {
99 foreach (EntityBase child in children) 99 foreach (EntityBase child in children)
100 { 100 {
101 child.updateMovement(); 101 child.updateMovement();
102 } 102 }
103 } 103 }
104 104
105 /// <summary> 105 /// <summary>
106 /// Performs any updates that need to be done at each frame. This function is overridable from it's children. 106 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
107 /// </summary> 107 /// </summary>
108 public virtual void update() 108 public virtual void update()
109 { 109 {
110 // Do any per-frame updates needed that are applicable to every type of entity 110 // Do any per-frame updates needed that are applicable to every type of entity
111 foreach (EntityBase child in children) 111 foreach (EntityBase child in children)
112 { 112 {
113 child.update(); 113 child.update();
114 } 114 }
115 } 115 }
116 116
117 /// <summary> 117 /// <summary>
118 /// Called at a set interval to inform entities that they should back themsleves up to the DB 118 /// Called at a set interval to inform entities that they should back themsleves up to the DB
119 /// </summary> 119 /// </summary>
120 public virtual void BackUp() 120 public virtual void BackUp()
121 { 121 {
122 122
123 } 123 }
124 124
125 /// <summary> 125 /// <summary>
126 /// Copies the entity 126 /// Copies the entity
127 /// </summary> 127 /// </summary>
128 /// <returns></returns> 128 /// <returns></returns>
129 public virtual EntityBase Copy() 129 public virtual EntityBase Copy()
130 { 130 {
131 return (EntityBase)this.MemberwiseClone(); 131 return (EntityBase)this.MemberwiseClone();
132 } 132 }
133 133
134 /// <summary> 134 /// <summary>
135 /// Infoms the entity that the land (heightmap) has changed 135 /// Infoms the entity that the land (heightmap) has changed
136 /// </summary> 136 /// </summary>
137 public virtual void LandRenegerated() 137 public virtual void LandRenegerated()
138 { 138 {
139 139
140 } 140 }
141 } 141 }
142} 142}
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
index 7c3a033..8551b70 100644
--- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
+++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
@@ -1,14 +1,14 @@
1using libsecondlife; 1using libsecondlife;
2using libsecondlife.Packets; 2using libsecondlife.Packets;
3using OpenSim.Framework.Interfaces; 3using OpenSim.Framework.Interfaces;
4 4
5namespace OpenSim.Region.Environment.Scenes 5namespace OpenSim.Region.Environment.Scenes
6{ 6{
7 public interface IScenePresenceBody 7 public interface IScenePresenceBody
8 { 8 {
9 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); 9 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
10 void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); 10 void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
11 void SendOurAppearance(IClientAPI OurClient); 11 void SendOurAppearance(IClientAPI OurClient);
12 void SendAppearanceToOtherAgent(ScenePresence avatarInfo); 12 void SendAppearanceToOtherAgent(ScenePresence avatarInfo);
13 } 13 }
14} 14}
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs
index 0e5b083..b413758 100644
--- a/OpenSim/Region/Environment/Scenes/Primitive.cs
+++ b/OpenSim/Region/Environment/Scenes/Primitive.cs
@@ -1,648 +1,648 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using Axiom.Math; 3using Axiom.Math;
4using libsecondlife; 4using libsecondlife;
5using libsecondlife.Packets; 5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces; 6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Inventory; 7using OpenSim.Framework.Inventory;
8using OpenSim.Framework.Types; 8using OpenSim.Framework.Types;
9 9
10namespace OpenSim.Region.Environment.Scenes 10namespace OpenSim.Region.Environment.Scenes
11{ 11{
12 public delegate void PrimCountTaintedDelegate(); 12 public delegate void PrimCountTaintedDelegate();
13 13
14 public class Primitive : EntityBase 14 public class Primitive : EntityBase
15 { 15 {
16 private const uint FULL_MASK_PERMISSIONS = 2147483647; 16 private const uint FULL_MASK_PERMISSIONS = 2147483647;
17 17
18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
19 private ulong m_regionHandle; 19 private ulong m_regionHandle;
20 private byte updateFlag = 0; 20 private byte updateFlag = 0;
21 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; 21 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
22 22
23 private Dictionary<LLUUID, InventoryItem> inventoryItems; 23 private Dictionary<LLUUID, InventoryItem> inventoryItems;
24 24
25 private string m_description = ""; 25 private string m_description = "";
26 26
27 public string SitName = ""; 27 public string SitName = "";
28 public string TouchName = ""; 28 public string TouchName = "";
29 public string Text = ""; 29 public string Text = "";
30 30
31 public LLUUID CreatorID; 31 public LLUUID CreatorID;
32 public LLUUID OwnerID; 32 public LLUUID OwnerID;
33 public LLUUID LastOwnerID; 33 public LLUUID LastOwnerID;
34 public Int32 CreationDate; 34 public Int32 CreationDate;
35 35
36 public uint ParentID = 0; 36 public uint ParentID = 0;
37 37
38 public uint OwnerMask = FULL_MASK_PERMISSIONS; 38 public uint OwnerMask = FULL_MASK_PERMISSIONS;
39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS; 39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
40 public uint GroupMask = FULL_MASK_PERMISSIONS; 40 public uint GroupMask = FULL_MASK_PERMISSIONS;
41 public uint EveryoneMask = FULL_MASK_PERMISSIONS; 41 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
42 public uint BaseMask = FULL_MASK_PERMISSIONS; 42 public uint BaseMask = FULL_MASK_PERMISSIONS;
43 43
44 private PrimitiveBaseShape m_Shape; 44 private PrimitiveBaseShape m_Shape;
45 45
46 public SceneObject m_RootParent; 46 public SceneObject m_RootParent;
47 public bool m_isRootPrim; 47 public bool m_isRootPrim;
48 public EntityBase m_Parent; 48 public EntityBase m_Parent;
49 49
50 private EventManager m_eventManager; 50 private EventManager m_eventManager;
51 51
52 public event PrimCountTaintedDelegate OnPrimCountTainted; 52 public event PrimCountTaintedDelegate OnPrimCountTainted;
53 53
54 #region Properties 54 #region Properties
55 /// <summary> 55 /// <summary>
56 /// If rootprim, will return world position 56 /// If rootprim, will return world position
57 /// otherwise will return local offset from rootprim 57 /// otherwise will return local offset from rootprim
58 /// </summary> 58 /// </summary>
59 public override LLVector3 Pos 59 public override LLVector3 Pos
60 { 60 {
61 get 61 get
62 { 62 {
63 if (m_isRootPrim) 63 if (m_isRootPrim)
64 { 64 {
65 //if we are rootprim then our offset should be zero 65 //if we are rootprim then our offset should be zero
66 return this.m_pos + m_Parent.Pos; 66 return this.m_pos + m_Parent.Pos;
67 } 67 }
68 else 68 else
69 { 69 {
70 return this.m_pos; 70 return this.m_pos;
71 } 71 }
72 } 72 }
73 set 73 set
74 { 74 {
75 if (m_isRootPrim) 75 if (m_isRootPrim)
76 { 76 {
77 m_Parent.Pos = value; 77 m_Parent.Pos = value;
78 } 78 }
79 this.m_pos = value - m_Parent.Pos; 79 this.m_pos = value - m_Parent.Pos;
80 } 80 }
81 81
82 } 82 }
83 83
84 public PrimitiveBaseShape Shape 84 public PrimitiveBaseShape Shape
85 { 85 {
86 get 86 get
87 { 87 {
88 return this.m_Shape; 88 return this.m_Shape;
89 } 89 }
90 } 90 }
91 91
92 public LLVector3 WorldPos 92 public LLVector3 WorldPos
93 { 93 {
94 get 94 get
95 { 95 {
96 if (!this.m_isRootPrim) 96 if (!this.m_isRootPrim)
97 { 97 {
98 Primitive parentPrim = (Primitive)this.m_Parent; 98 Primitive parentPrim = (Primitive)this.m_Parent;
99 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); 99 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
100 offsetPos = parentPrim.Rotation * offsetPos; 100 offsetPos = parentPrim.Rotation * offsetPos;
101 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); 101 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
102 } 102 }
103 else 103 else
104 { 104 {
105 return this.Pos; 105 return this.Pos;
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 public string Description 110 public string Description
111 { 111 {
112 get 112 get
113 { 113 {
114 return this.m_description; 114 return this.m_description;
115 } 115 }
116 set 116 set
117 { 117 {
118 this.m_description = value; 118 this.m_description = value;
119 } 119 }
120 } 120 }
121 121
122 public LLVector3 Scale 122 public LLVector3 Scale
123 { 123 {
124 set 124 set
125 { 125 {
126 this.m_Shape.Scale = value; 126 this.m_Shape.Scale = value;
127 } 127 }
128 get 128 get
129 { 129 {
130 return this.m_Shape.Scale; 130 return this.m_Shape.Scale;
131 } 131 }
132 } 132 }
133 #endregion 133 #endregion
134 134
135 #region Constructors 135 #region Constructors
136 /// <summary> 136 /// <summary>
137 /// 137 ///
138 /// </summary> 138 /// </summary>
139 /// <param name="regionHandle"></param> 139 /// <param name="regionHandle"></param>
140 /// <param name="world"></param> 140 /// <param name="world"></param>
141 /// <param name="addPacket"></param> 141 /// <param name="addPacket"></param>
142 /// <param name="ownerID"></param> 142 /// <param name="ownerID"></param>
143 /// <param name="localID"></param> 143 /// <param name="localID"></param>
144 /// <param name="isRoot"></param> 144 /// <param name="isRoot"></param>
145 /// <param name="parent"></param> 145 /// <param name="parent"></param>
146 /// <param name="rootObject"></param> 146 /// <param name="rootObject"></param>
147 public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) 147 public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
148 { 148 {
149 149
150 m_regionHandle = regionHandle; 150 m_regionHandle = regionHandle;
151 m_world = world; 151 m_world = world;
152 inventoryItems = new Dictionary<LLUUID, InventoryItem>(); 152 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
153 this.m_Parent = parent; 153 this.m_Parent = parent;
154 this.m_isRootPrim = isRoot; 154 this.m_isRootPrim = isRoot;
155 this.m_RootParent = rootObject; 155 this.m_RootParent = rootObject;
156 this.CreateFromShape(ownerID, localID, pos, shape); 156 this.CreateFromShape(ownerID, localID, pos, shape);
157 this.Rotation = Axiom.Math.Quaternion.Identity; 157 this.Rotation = Axiom.Math.Quaternion.Identity;
158 158
159 m_world.AcknowledgeNewPrim(this); 159 m_world.AcknowledgeNewPrim(this);
160 160
161 this.OnPrimCountTainted(); 161 this.OnPrimCountTainted();
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// 165 ///
166 /// </summary> 166 /// </summary>
167 /// <remarks>Empty constructor for duplication</remarks> 167 /// <remarks>Empty constructor for duplication</remarks>
168 public Primitive() 168 public Primitive()
169 { 169 {
170 170
171 } 171 }
172 172
173 #endregion 173 #endregion
174 174
175 #region Destructors 175 #region Destructors
176 176
177 ~Primitive() 177 ~Primitive()
178 { 178 {
179 this.OnPrimCountTainted(); 179 this.OnPrimCountTainted();
180 } 180 }
181 #endregion 181 #endregion
182 182
183 #region Duplication 183 #region Duplication
184 184
185 public Primitive Copy(EntityBase parent, SceneObject rootParent) 185 public Primitive Copy(EntityBase parent, SceneObject rootParent)
186 { 186 {
187 Primitive dupe = (Primitive)this.MemberwiseClone(); 187 Primitive dupe = (Primitive)this.MemberwiseClone();
188 188
189 dupe.m_Parent = parent; 189 dupe.m_Parent = parent;
190 dupe.m_RootParent = rootParent; 190 dupe.m_RootParent = rootParent;
191 191
192 // TODO: Copy this properly. 192 // TODO: Copy this properly.
193 dupe.inventoryItems = this.inventoryItems; 193 dupe.inventoryItems = this.inventoryItems;
194 dupe.children = new List<EntityBase>(); 194 dupe.children = new List<EntityBase>();
195 dupe.m_Shape = this.m_Shape.Copy(); 195 dupe.m_Shape = this.m_Shape.Copy();
196 dupe.m_regionHandle = this.m_regionHandle; 196 dupe.m_regionHandle = this.m_regionHandle;
197 dupe.m_world = this.m_world; 197 dupe.m_world = this.m_world;
198 198
199 uint newLocalID = this.m_world.PrimIDAllocate(); 199 uint newLocalID = this.m_world.PrimIDAllocate();
200 dupe.uuid = LLUUID.Random(); 200 dupe.uuid = LLUUID.Random();
201 dupe.LocalId = newLocalID; 201 dupe.LocalId = newLocalID;
202 202
203 if (parent is SceneObject) 203 if (parent is SceneObject)
204 { 204 {
205 dupe.m_isRootPrim = true; 205 dupe.m_isRootPrim = true;
206 dupe.ParentID = 0; 206 dupe.ParentID = 0;
207 } 207 }
208 else 208 else
209 { 209 {
210 dupe.m_isRootPrim = false; 210 dupe.m_isRootPrim = false;
211 dupe.ParentID = ((Primitive)parent).LocalId; 211 dupe.ParentID = ((Primitive)parent).LocalId;
212 } 212 }
213 213
214 dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); 214 dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z);
215 dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 215 dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
216 dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); 216 dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
217 217
218 rootParent.AddChildToList(dupe); 218 rootParent.AddChildToList(dupe);
219 this.m_world.AcknowledgeNewPrim(dupe); 219 this.m_world.AcknowledgeNewPrim(dupe);
220 dupe.TriggerOnPrimCountTainted(); 220 dupe.TriggerOnPrimCountTainted();
221 221
222 foreach (Primitive prim in this.children) 222 foreach (Primitive prim in this.children)
223 { 223 {
224 Primitive primClone = prim.Copy(dupe, rootParent); 224 Primitive primClone = prim.Copy(dupe, rootParent);
225 dupe.children.Add(primClone); 225 dupe.children.Add(primClone);
226 } 226 }
227 227
228 return dupe; 228 return dupe;
229 } 229 }
230 230
231 #endregion 231 #endregion
232 232
233 #region Override from EntityBase 233 #region Override from EntityBase
234 /// <summary> 234 /// <summary>
235 /// 235 ///
236 /// </summary> 236 /// </summary>
237 public override void update() 237 public override void update()
238 { 238 {
239 if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes 239 if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes
240 { 240 {
241 this.SendFullUpdateToAllClients(); 241 this.SendFullUpdateToAllClients();
242 this.updateFlag = 0; 242 this.updateFlag = 0;
243 } 243 }
244 if (this.updateFlag == 2) //some change has been made so update the clients 244 if (this.updateFlag == 2) //some change has been made so update the clients
245 { 245 {
246 this.SendTerseUpdateToALLClients(); 246 this.SendTerseUpdateToALLClients();
247 this.updateFlag = 0; 247 this.updateFlag = 0;
248 } 248 }
249 249
250 foreach (EntityBase child in children) 250 foreach (EntityBase child in children)
251 { 251 {
252 child.update(); 252 child.update();
253 } 253 }
254 } 254 }
255 #endregion 255 #endregion
256 256
257 #region Setup 257 #region Setup
258 /// <summary> 258 /// <summary>
259 /// 259 ///
260 /// </summary> 260 /// </summary>
261 /// <param name="addPacket"></param> 261 /// <param name="addPacket"></param>
262 /// <param name="ownerID"></param> 262 /// <param name="ownerID"></param>
263 /// <param name="localID"></param> 263 /// <param name="localID"></param>
264 public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) 264 public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
265 { 265 {
266 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 266 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
267 this.OwnerID = ownerID; 267 this.OwnerID = ownerID;
268 this.CreatorID = this.OwnerID; 268 this.CreatorID = this.OwnerID;
269 this.LastOwnerID = LLUUID.Zero; 269 this.LastOwnerID = LLUUID.Zero;
270 this.Pos = pos; 270 this.Pos = pos;
271 this.uuid = LLUUID.Random(); 271 this.uuid = LLUUID.Random();
272 this.m_localId = (uint)(localID); 272 this.m_localId = (uint)(localID);
273 273
274 this.m_Shape = shape; 274 this.m_Shape = shape;
275 this.updateFlag = 1; 275 this.updateFlag = 1;
276 } 276 }
277 277
278 #endregion 278 #endregion
279 279
280 #region Linking / unlinking 280 #region Linking / unlinking
281 /// <summary> 281 /// <summary>
282 /// 282 ///
283 /// </summary> 283 /// </summary>
284 /// <param name="linkObject"></param> 284 /// <param name="linkObject"></param>
285 public void AddNewChildren(SceneObject linkObject) 285 public void AddNewChildren(SceneObject linkObject)
286 { 286 {
287 // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); 287 // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")");
288 //TODO check permissions 288 //TODO check permissions
289 this.children.Add(linkObject.rootPrimitive); 289 this.children.Add(linkObject.rootPrimitive);
290 linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); 290 linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent);
291 291
292 this.m_world.DeleteEntity(linkObject.rootUUID); 292 this.m_world.DeleteEntity(linkObject.rootUUID);
293 linkObject.DeleteAllChildren(); 293 linkObject.DeleteAllChildren();
294 294
295 this.OnPrimCountTainted(); 295 this.OnPrimCountTainted();
296 } 296 }
297 297
298 /// <summary> 298 /// <summary>
299 /// 299 ///
300 /// </summary> 300 /// </summary>
301 /// <param name="newParent"></param> 301 /// <param name="newParent"></param>
302 /// <param name="rootParent"></param> 302 /// <param name="rootParent"></param>
303 public void SetNewParent(Primitive newParent, SceneObject rootParent) 303 public void SetNewParent(Primitive newParent, SceneObject rootParent)
304 { 304 {
305 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); 305 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
306 this.m_isRootPrim = false; 306 this.m_isRootPrim = false;
307 this.m_Parent = newParent; 307 this.m_Parent = newParent;
308 this.ParentID = newParent.LocalId; 308 this.ParentID = newParent.LocalId;
309 this.m_RootParent = rootParent; 309 this.m_RootParent = rootParent;
310 this.m_RootParent.AddChildToList(this); 310 this.m_RootParent.AddChildToList(this);
311 this.Pos = oldPos; 311 this.Pos = oldPos;
312 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 312 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
313 axPos = this.m_Parent.Rotation.Inverse() * axPos; 313 axPos = this.m_Parent.Rotation.Inverse() * axPos;
314 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 314 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
315 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 315 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
316 this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation; 316 this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation;
317 this.updateFlag = 1; 317 this.updateFlag = 1;
318 318
319 foreach (Primitive child in children) 319 foreach (Primitive child in children)
320 { 320 {
321 child.SetRootParent(rootParent, newParent, oldPos, oldRot); 321 child.SetRootParent(rootParent, newParent, oldPos, oldRot);
322 } 322 }
323 children.Clear(); 323 children.Clear();
324 324
325 325
326 } 326 }
327 327
328 /// <summary> 328 /// <summary>
329 /// 329 ///
330 /// </summary> 330 /// </summary>
331 /// <param name="newRoot"></param> 331 /// <param name="newRoot"></param>
332 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation) 332 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
333 { 333 {
334 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); 334 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
335 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); 335 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
336 axOldPos = oldParentRotation * axOldPos; 336 axOldPos = oldParentRotation * axOldPos;
337 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); 337 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
338 oldPos += oldParentPosition; 338 oldPos += oldParentPosition;
339 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 339 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
340 this.m_isRootPrim = false; 340 this.m_isRootPrim = false;
341 this.m_Parent = newParent; 341 this.m_Parent = newParent;
342 this.ParentID = newParent.LocalId; 342 this.ParentID = newParent.LocalId;
343 newParent.AddToChildrenList(this); 343 newParent.AddToChildrenList(this);
344 this.m_RootParent = newRoot; 344 this.m_RootParent = newRoot;
345 this.m_RootParent.AddChildToList(this); 345 this.m_RootParent.AddChildToList(this);
346 this.Pos = oldPos; 346 this.Pos = oldPos;
347 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 347 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
348 axPos = this.m_Parent.Rotation.Inverse() * axPos; 348 axPos = this.m_Parent.Rotation.Inverse() * axPos;
349 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 349 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
350 this.Rotation = oldParentRotation * this.Rotation; 350 this.Rotation = oldParentRotation * this.Rotation;
351 this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ; 351 this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ;
352 this.updateFlag = 1; 352 this.updateFlag = 1;
353 foreach (Primitive child in children) 353 foreach (Primitive child in children)
354 { 354 {
355 child.SetRootParent(newRoot, newParent, oldPos, oldRot); 355 child.SetRootParent(newRoot, newParent, oldPos, oldRot);
356 } 356 }
357 children.Clear(); 357 children.Clear();
358 } 358 }
359 359
360 /// <summary> 360 /// <summary>
361 /// 361 ///
362 /// </summary> 362 /// </summary>
363 /// <param name="offset"></param> 363 /// <param name="offset"></param>
364 public void AddOffsetToChildren(LLVector3 offset) 364 public void AddOffsetToChildren(LLVector3 offset)
365 { 365 {
366 foreach (Primitive prim in this.children) 366 foreach (Primitive prim in this.children)
367 { 367 {
368 prim.m_pos += offset; 368 prim.m_pos += offset;
369 prim.updateFlag = 2; 369 prim.updateFlag = 2;
370 } 370 }
371 this.OnPrimCountTainted(); 371 this.OnPrimCountTainted();
372 } 372 }
373 373
374 /// <summary> 374 /// <summary>
375 /// 375 ///
376 /// </summary> 376 /// </summary>
377 /// <param name="prim"></param> 377 /// <param name="prim"></param>
378 public void AddToChildrenList(Primitive prim) 378 public void AddToChildrenList(Primitive prim)
379 { 379 {
380 this.children.Add(prim); 380 this.children.Add(prim);
381 } 381 }
382 #endregion 382 #endregion
383 383
384 #region Resizing/Scale 384 #region Resizing/Scale
385 /// <summary> 385 /// <summary>
386 /// 386 ///
387 /// </summary> 387 /// </summary>
388 /// <param name="scale"></param> 388 /// <param name="scale"></param>
389 public void ResizeGoup(LLVector3 scale) 389 public void ResizeGoup(LLVector3 scale)
390 { 390 {
391 LLVector3 offset = (scale - this.m_Shape.Scale); 391 LLVector3 offset = (scale - this.m_Shape.Scale);
392 offset.X /= 2; 392 offset.X /= 2;
393 offset.Y /= 2; 393 offset.Y /= 2;
394 offset.Z /= 2; 394 offset.Z /= 2;
395 if (this.m_isRootPrim) 395 if (this.m_isRootPrim)
396 { 396 {
397 this.m_Parent.Pos += offset; 397 this.m_Parent.Pos += offset;
398 } 398 }
399 else 399 else
400 { 400 {
401 this.m_pos += offset; 401 this.m_pos += offset;
402 } 402 }
403 403
404 this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); 404 this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
405 this.m_Shape.Scale = scale; 405 this.m_Shape.Scale = scale;
406 406
407 this.updateFlag = 1; 407 this.updateFlag = 1;
408 } 408 }
409 #endregion 409 #endregion
410 410
411 #region Position 411 #region Position
412 /// <summary> 412 /// <summary>
413 /// 413 ///
414 /// </summary> 414 /// </summary>
415 /// <param name="pos"></param> 415 /// <param name="pos"></param>
416 public void UpdateGroupPosition(LLVector3 pos) 416 public void UpdateGroupPosition(LLVector3 pos)
417 { 417 {
418 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 418 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
419 419
420 this.Pos = newPos; 420 this.Pos = newPos;
421 this.updateFlag = 2; 421 this.updateFlag = 2;
422 422
423 this.OnPrimCountTainted(); 423 this.OnPrimCountTainted();
424 } 424 }
425 425
426 /// <summary> 426 /// <summary>
427 /// 427 ///
428 /// </summary> 428 /// </summary>
429 /// <param name="pos"></param> 429 /// <param name="pos"></param>
430 public void UpdateSinglePosition(LLVector3 pos) 430 public void UpdateSinglePosition(LLVector3 pos)
431 { 431 {
432 // Console.WriteLine("updating single prim position"); 432 // Console.WriteLine("updating single prim position");
433 if (this.m_isRootPrim) 433 if (this.m_isRootPrim)
434 { 434 {
435 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 435 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
436 LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); 436 LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
437 LLVector3 diff = oldPos - newPos; 437 LLVector3 diff = oldPos - newPos;
438 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); 438 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
439 axDiff = this.Rotation.Inverse() * axDiff; 439 axDiff = this.Rotation.Inverse() * axDiff;
440 diff.X = axDiff.x; 440 diff.X = axDiff.x;
441 diff.Y = axDiff.y; 441 diff.Y = axDiff.y;
442 diff.Z = axDiff.z; 442 diff.Z = axDiff.z;
443 this.Pos = newPos; 443 this.Pos = newPos;
444 444
445 foreach (Primitive prim in this.children) 445 foreach (Primitive prim in this.children)
446 { 446 {
447 prim.m_pos += diff; 447 prim.m_pos += diff;
448 prim.updateFlag = 2; 448 prim.updateFlag = 2;
449 } 449 }
450 this.updateFlag = 2; 450 this.updateFlag = 2;
451 } 451 }
452 else 452 else
453 { 453 {
454 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 454 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
455 this.m_pos = newPos; 455 this.m_pos = newPos;
456 this.updateFlag = 2; 456 this.updateFlag = 2;
457 } 457 }
458 458
459 459
460 } 460 }
461 461
462 #endregion 462 #endregion
463 463
464 #region Rotation 464 #region Rotation
465 /// <summary> 465 /// <summary>
466 /// 466 ///
467 /// </summary> 467 /// </summary>
468 /// <param name="rot"></param> 468 /// <param name="rot"></param>
469 public void UpdateGroupRotation(LLQuaternion rot) 469 public void UpdateGroupRotation(LLQuaternion rot)
470 { 470 {
471 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 471 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
472 this.updateFlag = 2; 472 this.updateFlag = 2;
473 473
474 } 474 }
475 475
476 /// <summary> 476 /// <summary>
477 /// 477 ///
478 /// </summary> 478 /// </summary>
479 /// <param name="pos"></param> 479 /// <param name="pos"></param>
480 /// <param name="rot"></param> 480 /// <param name="rot"></param>
481 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) 481 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
482 { 482 {
483 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 483 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
484 this.Pos = pos; 484 this.Pos = pos;
485 this.updateFlag = 2; 485 this.updateFlag = 2;
486 } 486 }
487 487
488 /// <summary> 488 /// <summary>
489 /// 489 ///
490 /// </summary> 490 /// </summary>
491 /// <param name="rot"></param> 491 /// <param name="rot"></param>
492 public void UpdateSingleRotation(LLQuaternion rot) 492 public void UpdateSingleRotation(LLQuaternion rot)
493 { 493 {
494 //Console.WriteLine("updating single prim rotation"); 494 //Console.WriteLine("updating single prim rotation");
495 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 495 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
496 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 496 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
497 this.Rotation = axRot; 497 this.Rotation = axRot;
498 foreach (Primitive prim in this.children) 498 foreach (Primitive prim in this.children)
499 { 499 {
500 Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); 500 Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z);
501 axPos = oldParentRot * axPos; 501 axPos = oldParentRot * axPos;
502 axPos = axRot.Inverse() * axPos; 502 axPos = axRot.Inverse() * axPos;
503 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 503 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
504 prim.Rotation = oldParentRot * prim.Rotation ; 504 prim.Rotation = oldParentRot * prim.Rotation ;
505 prim.Rotation = axRot.Inverse()* prim.Rotation; 505 prim.Rotation = axRot.Inverse()* prim.Rotation;
506 prim.updateFlag = 2; 506 prim.updateFlag = 2;
507 } 507 }
508 this.updateFlag = 2; 508 this.updateFlag = 2;
509 } 509 }
510 #endregion 510 #endregion
511 511
512 #region Shape 512 #region Shape
513 /// <summary> 513 /// <summary>
514 /// 514 ///
515 /// </summary> 515 /// </summary>
516 /// <param name="shapeBlock"></param> 516 /// <param name="shapeBlock"></param>
517 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) 517 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
518 { 518 {
519 this.m_Shape.PathBegin = shapeBlock.PathBegin; 519 this.m_Shape.PathBegin = shapeBlock.PathBegin;
520 this.m_Shape.PathEnd = shapeBlock.PathEnd; 520 this.m_Shape.PathEnd = shapeBlock.PathEnd;
521 this.m_Shape.PathScaleX = shapeBlock.PathScaleX; 521 this.m_Shape.PathScaleX = shapeBlock.PathScaleX;
522 this.m_Shape.PathScaleY = shapeBlock.PathScaleY; 522 this.m_Shape.PathScaleY = shapeBlock.PathScaleY;
523 this.m_Shape.PathShearX = shapeBlock.PathShearX; 523 this.m_Shape.PathShearX = shapeBlock.PathShearX;
524 this.m_Shape.PathShearY = shapeBlock.PathShearY; 524 this.m_Shape.PathShearY = shapeBlock.PathShearY;
525 this.m_Shape.PathSkew = shapeBlock.PathSkew; 525 this.m_Shape.PathSkew = shapeBlock.PathSkew;
526 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; 526 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
527 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; 527 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
528 this.m_Shape.PathCurve = shapeBlock.PathCurve; 528 this.m_Shape.PathCurve = shapeBlock.PathCurve;
529 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; 529 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
530 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; 530 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
531 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; 531 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
532 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; 532 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
533 this.m_Shape.PathTaperX = shapeBlock.PathTaperX; 533 this.m_Shape.PathTaperX = shapeBlock.PathTaperX;
534 this.m_Shape.PathTaperY = shapeBlock.PathTaperY; 534 this.m_Shape.PathTaperY = shapeBlock.PathTaperY;
535 this.m_Shape.PathTwist = shapeBlock.PathTwist; 535 this.m_Shape.PathTwist = shapeBlock.PathTwist;
536 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; 536 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
537 this.updateFlag = 1; 537 this.updateFlag = 1;
538 } 538 }
539 #endregion 539 #endregion
540 540
541 #region Texture 541 #region Texture
542 /// <summary> 542 /// <summary>
543 /// 543 ///
544 /// </summary> 544 /// </summary>
545 /// <param name="textureEntry"></param> 545 /// <param name="textureEntry"></param>
546 public void UpdateTextureEntry(byte[] textureEntry) 546 public void UpdateTextureEntry(byte[] textureEntry)
547 { 547 {
548 this.m_Shape.TextureEntry = textureEntry; 548 this.m_Shape.TextureEntry = textureEntry;
549 this.updateFlag = 1; 549 this.updateFlag = 1;
550 } 550 }
551 #endregion 551 #endregion
552 552
553 #region Client Update Methods 553 #region Client Update Methods
554 554
555 /// <summary> 555 /// <summary>
556 /// 556 ///
557 /// </summary> 557 /// </summary>
558 /// <param name="remoteClient"></param> 558 /// <param name="remoteClient"></param>
559 public void SendFullUpdateForAllChildren(IClientAPI remoteClient) 559 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
560 { 560 {
561 this.SendFullUpdateToClient(remoteClient); 561 this.SendFullUpdateToClient(remoteClient);
562 for (int i = 0; i < this.children.Count; i++) 562 for (int i = 0; i < this.children.Count; i++)
563 { 563 {
564 if (this.children[i] is Primitive) 564 if (this.children[i] is Primitive)
565 { 565 {
566 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); 566 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
567 } 567 }
568 } 568 }
569 } 569 }
570 570
571 /// <summary> 571 /// <summary>
572 /// 572 ///
573 /// </summary> 573 /// </summary>
574 /// <param name="remoteClient"></param> 574 /// <param name="remoteClient"></param>
575 public void SendFullUpdateToClient(IClientAPI remoteClient) 575 public void SendFullUpdateToClient(IClientAPI remoteClient)
576 { 576 {
577 LLVector3 lPos; 577 LLVector3 lPos;
578 lPos = this.Pos; 578 lPos = this.Pos;
579 LLQuaternion lRot; 579 LLQuaternion lRot;
580 lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w); 580 lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w);
581 581
582 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID); 582 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID);
583 } 583 }
584 584
585 /// <summary> 585 /// <summary>
586 /// 586 ///
587 /// </summary> 587 /// </summary>
588 public void SendFullUpdateToAllClients() 588 public void SendFullUpdateToAllClients()
589 { 589 {
590 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 590 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
591 for (int i = 0; i < avatars.Count; i++) 591 for (int i = 0; i < avatars.Count; i++)
592 { 592 {
593 this.SendFullUpdateToClient(avatars[i].ControllingClient); 593 this.SendFullUpdateToClient(avatars[i].ControllingClient);
594 } 594 }
595 } 595 }
596 596
597 /// <summary> 597 /// <summary>
598 /// 598 ///
599 /// </summary> 599 /// </summary>
600 /// <param name="remoteClient"></param> 600 /// <param name="remoteClient"></param>
601 public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) 601 public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
602 { 602 {
603 this.SendTerseUpdateToClient(remoteClient); 603 this.SendTerseUpdateToClient(remoteClient);
604 for (int i = 0; i < this.children.Count; i++) 604 for (int i = 0; i < this.children.Count; i++)
605 { 605 {
606 if (this.children[i] is Primitive) 606 if (this.children[i] is Primitive)
607 { 607 {
608 ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient); 608 ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient);
609 } 609 }
610 } 610 }
611 } 611 }
612 612
613 /// <summary> 613 /// <summary>
614 /// 614 ///
615 /// </summary> 615 /// </summary>
616 /// <param name="RemoteClient"></param> 616 /// <param name="RemoteClient"></param>
617 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 617 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
618 { 618 {
619 LLVector3 lPos; 619 LLVector3 lPos;
620 Quaternion lRot; 620 Quaternion lRot;
621 621
622 lPos = this.Pos; 622 lPos = this.Pos;
623 lRot = this.Rotation; 623 lRot = this.Rotation;
624 624
625 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); 625 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
626 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); 626 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
627 } 627 }
628 628
629 /// <summary> 629 /// <summary>
630 /// 630 ///
631 /// </summary> 631 /// </summary>
632 public void SendTerseUpdateToALLClients() 632 public void SendTerseUpdateToALLClients()
633 { 633 {
634 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 634 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
635 for (int i = 0; i < avatars.Count; i++) 635 for (int i = 0; i < avatars.Count; i++)
636 { 636 {
637 this.SendTerseUpdateToClient(avatars[i].ControllingClient); 637 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
638 } 638 }
639 } 639 }
640 640
641 #endregion 641 #endregion
642 642
643 public void TriggerOnPrimCountTainted() 643 public void TriggerOnPrimCountTainted()
644 { 644 {
645 this.OnPrimCountTainted(); 645 this.OnPrimCountTainted();
646 } 646 }
647 } 647 }
648} 648}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index 347625a..e37d105 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -1,618 +1,618 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34 34
35namespace OpenSim.Region.Environment.Scenes 35namespace OpenSim.Region.Environment.Scenes
36{ 36{
37 public partial class Scene 37 public partial class Scene
38 { 38 {
39 /// <summary> 39 /// <summary>
40 /// Modifies terrain using the specified information 40 /// Modifies terrain using the specified information
41 /// </summary> 41 /// </summary>
42 /// <param name="height">The height at which the user started modifying the terrain</param> 42 /// <param name="height">The height at which the user started modifying the terrain</param>
43 /// <param name="seconds">The number of seconds the modify button was pressed</param> 43 /// <param name="seconds">The number of seconds the modify button was pressed</param>
44 /// <param name="brushsize">The size of the brush used</param> 44 /// <param name="brushsize">The size of the brush used</param>
45 /// <param name="action">The action to be performed</param> 45 /// <param name="action">The action to be performed</param>
46 /// <param name="north">Distance from the north border where the cursor is located</param> 46 /// <param name="north">Distance from the north border where the cursor is located</param>
47 /// <param name="west">Distance from the west border where the cursor is located</param> 47 /// <param name="west">Distance from the west border where the cursor is located</param>
48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west) 48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west)
49 { 49 {
50 // Shiny. 50 // Shiny.
51 double size = (double)(1 << brushsize); 51 double size = (double)(1 << brushsize);
52 52
53 switch (action) 53 switch (action)
54 { 54 {
55 case 0: 55 case 0:
56 // flatten terrain 56 // flatten terrain
57 Terrain.flatten(north, west, size, (double)seconds / 100.0); 57 Terrain.flatten(north, west, size, (double)seconds / 100.0);
58 RegenerateTerrain(true, (int)north, (int)west); 58 RegenerateTerrain(true, (int)north, (int)west);
59 break; 59 break;
60 case 1: 60 case 1:
61 // raise terrain 61 // raise terrain
62 Terrain.raise(north, west, size, (double)seconds / 100.0); 62 Terrain.raise(north, west, size, (double)seconds / 100.0);
63 RegenerateTerrain(true, (int)north, (int)west); 63 RegenerateTerrain(true, (int)north, (int)west);
64 break; 64 break;
65 case 2: 65 case 2:
66 //lower terrain 66 //lower terrain
67 Terrain.lower(north, west, size, (double)seconds / 100.0); 67 Terrain.lower(north, west, size, (double)seconds / 100.0);
68 RegenerateTerrain(true, (int)north, (int)west); 68 RegenerateTerrain(true, (int)north, (int)west);
69 break; 69 break;
70 case 3: 70 case 3:
71 // smooth terrain 71 // smooth terrain
72 Terrain.smooth(north, west, size, (double)seconds / 100.0); 72 Terrain.smooth(north, west, size, (double)seconds / 100.0);
73 RegenerateTerrain(true, (int)north, (int)west); 73 RegenerateTerrain(true, (int)north, (int)west);
74 break; 74 break;
75 case 4: 75 case 4:
76 // noise 76 // noise
77 Terrain.noise(north, west, size, (double)seconds / 100.0); 77 Terrain.noise(north, west, size, (double)seconds / 100.0);
78 RegenerateTerrain(true, (int)north, (int)west); 78 RegenerateTerrain(true, (int)north, (int)west);
79 break; 79 break;
80 case 5: 80 case 5:
81 // revert 81 // revert
82 Terrain.revert(north, west, size, (double)seconds / 100.0); 82 Terrain.revert(north, west, size, (double)seconds / 100.0);
83 RegenerateTerrain(true, (int)north, (int)west); 83 RegenerateTerrain(true, (int)north, (int)west);
84 break; 84 break;
85 85
86 // CLIENT EXTENSIONS GO HERE 86 // CLIENT EXTENSIONS GO HERE
87 case 128: 87 case 128:
88 // erode-thermal 88 // erode-thermal
89 break; 89 break;
90 case 129: 90 case 129:
91 // erode-aerobic 91 // erode-aerobic
92 break; 92 break;
93 case 130: 93 case 130:
94 // erode-hydraulic 94 // erode-hydraulic
95 break; 95 break;
96 } 96 }
97 return; 97 return;
98 } 98 }
99 99
100 /// <summary> 100 /// <summary>
101 /// 101 ///
102 /// </summary> 102 /// </summary>
103 /// <remarks>Inefficient. TODO: Fixme</remarks> 103 /// <remarks>Inefficient. TODO: Fixme</remarks>
104 /// <param name="fromAgentID"></param> 104 /// <param name="fromAgentID"></param>
105 /// <param name="toAgentID"></param> 105 /// <param name="toAgentID"></param>
106 /// <param name="timestamp"></param> 106 /// <param name="timestamp"></param>
107 /// <param name="fromAgentName"></param> 107 /// <param name="fromAgentName"></param>
108 /// <param name="message"></param> 108 /// <param name="message"></param>
109 public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message) 109 public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message)
110 { 110 {
111 if (this.Avatars.ContainsKey(toAgentID)) 111 if (this.Avatars.ContainsKey(toAgentID))
112 { 112 {
113 if (this.Avatars.ContainsKey(fromAgentID)) 113 if (this.Avatars.ContainsKey(fromAgentID))
114 { 114 {
115 // Local sim message 115 // Local sim message
116 ScenePresence fromAvatar = this.Avatars[fromAgentID]; 116 ScenePresence fromAvatar = this.Avatars[fromAgentID];
117 ScenePresence toAvatar = this.Avatars[toAgentID]; 117 ScenePresence toAvatar = this.Avatars[toAgentID];
118 string fromName = fromAvatar.firstname + " " + fromAvatar.lastname; 118 string fromName = fromAvatar.firstname + " " + fromAvatar.lastname;
119 toAvatar.ControllingClient.SendInstantMessage(message, toAgentID, fromName); 119 toAvatar.ControllingClient.SendInstantMessage(message, toAgentID, fromName);
120 } 120 }
121 else 121 else
122 { 122 {
123 // Message came from a user outside the sim, ignore? 123 // Message came from a user outside the sim, ignore?
124 } 124 }
125 } 125 }
126 else 126 else
127 { 127 {
128 // Grid message 128 // Grid message
129 } 129 }
130 } 130 }
131 131
132 /// <summary> 132 /// <summary>
133 /// 133 ///
134 /// </summary> 134 /// </summary>
135 /// <param name="message"></param> 135 /// <param name="message"></param>
136 /// <param name="type"></param> 136 /// <param name="type"></param>
137 /// <param name="fromPos"></param> 137 /// <param name="fromPos"></param>
138 /// <param name="fromName"></param> 138 /// <param name="fromName"></param>
139 /// <param name="fromAgentID"></param> 139 /// <param name="fromAgentID"></param>
140 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 140 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
141 { 141 {
142 ScenePresence avatar = null; 142 ScenePresence avatar = null;
143 if (this.Avatars.ContainsKey(fromAgentID)) 143 if (this.Avatars.ContainsKey(fromAgentID))
144 { 144 {
145 avatar = this.Avatars[fromAgentID]; 145 avatar = this.Avatars[fromAgentID];
146 fromPos = avatar.Pos; 146 fromPos = avatar.Pos;
147 fromName = avatar.firstname + " " + avatar.lastname; 147 fromName = avatar.firstname + " " + avatar.lastname;
148 avatar = null; 148 avatar = null;
149 } 149 }
150 150
151 this.ForEachScenePresence(delegate(ScenePresence presence) 151 this.ForEachScenePresence(delegate(ScenePresence presence)
152 { 152 {
153 int dis = -1000; 153 int dis = -1000;
154 if (this.Avatars.ContainsKey(presence.ControllingClient.AgentId)) 154 if (this.Avatars.ContainsKey(presence.ControllingClient.AgentId))
155 { 155 {
156 avatar = this.Avatars[presence.ControllingClient.AgentId]; 156 avatar = this.Avatars[presence.ControllingClient.AgentId];
157 dis = (int)avatar.Pos.GetDistanceTo(fromPos); 157 dis = (int)avatar.Pos.GetDistanceTo(fromPos);
158 } 158 }
159 159
160 switch (type) 160 switch (type)
161 { 161 {
162 case 0: // Whisper 162 case 0: // Whisper
163 if ((dis < 10) && (dis > -10)) 163 if ((dis < 10) && (dis > -10))
164 { 164 {
165 //should change so the message is sent through the avatar rather than direct to the ClientView 165 //should change so the message is sent through the avatar rather than direct to the ClientView
166 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, 166 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
167 fromAgentID); 167 fromAgentID);
168 } 168 }
169 break; 169 break;
170 case 1: // Say 170 case 1: // Say
171 if ((dis < 30) && (dis > -30)) 171 if ((dis < 30) && (dis > -30))
172 { 172 {
173 //Console.WriteLine("sending chat"); 173 //Console.WriteLine("sending chat");
174 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, 174 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
175 fromAgentID); 175 fromAgentID);
176 } 176 }
177 break; 177 break;
178 case 2: // Shout 178 case 2: // Shout
179 if ((dis < 100) && (dis > -100)) 179 if ((dis < 100) && (dis > -100))
180 { 180 {
181 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, 181 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
182 fromAgentID); 182 fromAgentID);
183 } 183 }
184 break; 184 break;
185 185
186 case 0xff: // Broadcast 186 case 0xff: // Broadcast
187 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, 187 presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
188 fromAgentID); 188 fromAgentID);
189 break; 189 break;
190 } 190 }
191 }); 191 });
192 } 192 }
193 193
194 /// <summary> 194 /// <summary>
195 /// 195 ///
196 /// </summary> 196 /// </summary>
197 /// <param name="primAsset"></param> 197 /// <param name="primAsset"></param>
198 /// <param name="pos"></param> 198 /// <param name="pos"></param>
199 public void RezObject(AssetBase primAsset, LLVector3 pos) 199 public void RezObject(AssetBase primAsset, LLVector3 pos)
200 { 200 {
201 201
202 } 202 }
203 203
204 /// <summary> 204 /// <summary>
205 /// 205 ///
206 /// </summary> 206 /// </summary>
207 /// <param name="packet"></param> 207 /// <param name="packet"></param>
208 /// <param name="simClient"></param> 208 /// <param name="simClient"></param>
209 public void DeRezObject(Packet packet, IClientAPI simClient) 209 public void DeRezObject(Packet packet, IClientAPI simClient)
210 { 210 {
211 211
212 } 212 }
213 213
214 /// <summary> 214 /// <summary>
215 /// 215 ///
216 /// </summary> 216 /// </summary>
217 /// <param name="remoteClient"></param> 217 /// <param name="remoteClient"></param>
218 public void SendAvatarsToClient(IClientAPI remoteClient) 218 public void SendAvatarsToClient(IClientAPI remoteClient)
219 { 219 {
220 220
221 } 221 }
222 222
223 /// <summary> 223 /// <summary>
224 /// 224 ///
225 /// </summary> 225 /// </summary>
226 /// <param name="originalPrim"></param> 226 /// <param name="originalPrim"></param>
227 /// <param name="offset"></param> 227 /// <param name="offset"></param>
228 /// <param name="flags"></param> 228 /// <param name="flags"></param>
229 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) 229 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags)
230 { 230 {
231 SceneObject originPrim = null; 231 SceneObject originPrim = null;
232 foreach (EntityBase ent in Entities.Values) 232 foreach (EntityBase ent in Entities.Values)
233 { 233 {
234 if (ent is SceneObject) 234 if (ent is SceneObject)
235 { 235 {
236 if (((SceneObject)ent).rootLocalID == originalPrim) 236 if (((SceneObject)ent).rootLocalID == originalPrim)
237 { 237 {
238 originPrim = (SceneObject)ent; 238 originPrim = (SceneObject)ent;
239 break; 239 break;
240 } 240 }
241 } 241 }
242 } 242 }
243 243
244 if (originPrim != null) 244 if (originPrim != null)
245 { 245 {
246 SceneObject copy = originPrim.Copy(); 246 SceneObject copy = originPrim.Copy();
247 copy.Pos = copy.Pos + offset; 247 copy.Pos = copy.Pos + offset;
248 this.Entities.Add(copy.rootUUID, copy); 248 this.Entities.Add(copy.rootUUID, copy);
249 249
250 List<ScenePresence> avatars = this.RequestAvatarList(); 250 List<ScenePresence> avatars = this.RequestAvatarList();
251 for (int i = 0; i < avatars.Count; i++) 251 for (int i = 0; i < avatars.Count; i++)
252 { 252 {
253 copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); 253 copy.SendAllChildPrimsToClient(avatars[i].ControllingClient);
254 } 254 }
255 255
256 } 256 }
257 else 257 else
258 { 258 {
259 OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim"); 259 OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim");
260 } 260 }
261 261
262 } 262 }
263 263
264 /// <summary> 264 /// <summary>
265 /// 265 ///
266 /// </summary> 266 /// </summary>
267 /// <param name="parentPrim"></param> 267 /// <param name="parentPrim"></param>
268 /// <param name="childPrims"></param> 268 /// <param name="childPrims"></param>
269 public void LinkObjects(uint parentPrim, List<uint> childPrims) 269 public void LinkObjects(uint parentPrim, List<uint> childPrims)
270 { 270 {
271 SceneObject parenPrim = null; 271 SceneObject parenPrim = null;
272 foreach (EntityBase ent in Entities.Values) 272 foreach (EntityBase ent in Entities.Values)
273 { 273 {
274 if (ent is SceneObject) 274 if (ent is SceneObject)
275 { 275 {
276 if (((SceneObject)ent).rootLocalID == parentPrim) 276 if (((SceneObject)ent).rootLocalID == parentPrim)
277 { 277 {
278 parenPrim = (SceneObject)ent; 278 parenPrim = (SceneObject)ent;
279 break; 279 break;
280 } 280 }
281 } 281 }
282 } 282 }
283 283
284 List<SceneObject> children = new List<SceneObject>(); 284 List<SceneObject> children = new List<SceneObject>();
285 if (parenPrim != null) 285 if (parenPrim != null)
286 { 286 {
287 for (int i = 0; i < childPrims.Count; i++) 287 for (int i = 0; i < childPrims.Count; i++)
288 { 288 {
289 foreach (EntityBase ent in Entities.Values) 289 foreach (EntityBase ent in Entities.Values)
290 { 290 {
291 if (ent is SceneObject) 291 if (ent is SceneObject)
292 { 292 {
293 if (((SceneObject)ent).rootLocalID == childPrims[i]) 293 if (((SceneObject)ent).rootLocalID == childPrims[i])
294 { 294 {
295 children.Add((SceneObject)ent); 295 children.Add((SceneObject)ent);
296 } 296 }
297 } 297 }
298 } 298 }
299 } 299 }
300 } 300 }
301 301
302 foreach (SceneObject sceneObj in children) 302 foreach (SceneObject sceneObj in children)
303 { 303 {
304 parenPrim.AddNewChildPrims(sceneObj); 304 parenPrim.AddNewChildPrims(sceneObj);
305 } 305 }
306 } 306 }
307 307
308 /// <summary> 308 /// <summary>
309 /// 309 ///
310 /// </summary> 310 /// </summary>
311 /// <param name="primLocalID"></param> 311 /// <param name="primLocalID"></param>
312 /// <param name="shapeBlock"></param> 312 /// <param name="shapeBlock"></param>
313 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) 313 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
314 { 314 {
315 Primitive prim = null; 315 Primitive prim = null;
316 foreach (EntityBase ent in Entities.Values) 316 foreach (EntityBase ent in Entities.Values)
317 { 317 {
318 if (ent is SceneObject) 318 if (ent is SceneObject)
319 { 319 {
320 prim = ((SceneObject)ent).HasChildPrim(primLocalID); 320 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
321 if (prim != null) 321 if (prim != null)
322 { 322 {
323 prim.UpdateShape(shapeBlock); 323 prim.UpdateShape(shapeBlock);
324 break; 324 break;
325 } 325 }
326 } 326 }
327 } 327 }
328 } 328 }
329 329
330 /// <summary> 330 /// <summary>
331 /// 331 ///
332 /// </summary> 332 /// </summary>
333 /// <param name="primLocalID"></param> 333 /// <param name="primLocalID"></param>
334 /// <param name="remoteClient"></param> 334 /// <param name="remoteClient"></param>
335 public void SelectPrim(uint primLocalID, IClientAPI remoteClient) 335 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
336 { 336 {
337 foreach (EntityBase ent in Entities.Values) 337 foreach (EntityBase ent in Entities.Values)
338 { 338 {
339 if (ent is SceneObject) 339 if (ent is SceneObject)
340 { 340 {
341 if (((SceneObject)ent).rootLocalID == primLocalID) 341 if (((SceneObject)ent).rootLocalID == primLocalID)
342 { 342 {
343 ((SceneObject)ent).GetProperites(remoteClient); 343 ((SceneObject)ent).GetProperites(remoteClient);
344 ((SceneObject)ent).isSelected = true; 344 ((SceneObject)ent).isSelected = true;
345 this.ParcelManager.setPrimsTainted(); 345 this.ParcelManager.setPrimsTainted();
346 break; 346 break;
347 } 347 }
348 } 348 }
349 } 349 }
350 } 350 }
351 351
352 /// <summary> 352 /// <summary>
353 /// 353 ///
354 /// </summary> 354 /// </summary>
355 /// <param name="primLocalID"></param> 355 /// <param name="primLocalID"></param>
356 /// <param name="remoteClient"></param> 356 /// <param name="remoteClient"></param>
357 public void DeselectPrim(uint primLocalID, IClientAPI remoteClient) 357 public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
358 { 358 {
359 foreach (EntityBase ent in Entities.Values) 359 foreach (EntityBase ent in Entities.Values)
360 { 360 {
361 if (ent is SceneObject) 361 if (ent is SceneObject)
362 { 362 {
363 if (((SceneObject)ent).rootLocalID == primLocalID) 363 if (((SceneObject)ent).rootLocalID == primLocalID)
364 { 364 {
365 ((SceneObject)ent).isSelected = false; 365 ((SceneObject)ent).isSelected = false;
366 this.ParcelManager.setPrimsTainted(); 366 this.ParcelManager.setPrimsTainted();
367 break; 367 break;
368 } 368 }
369 } 369 }
370 } 370 }
371 } 371 }
372 372
373 /// <summary> 373 /// <summary>
374 /// 374 ///
375 /// </summary> 375 /// </summary>
376 /// <param name="primLocalID"></param> 376 /// <param name="primLocalID"></param>
377 /// <param name="description"></param> 377 /// <param name="description"></param>
378 public void PrimDescription(uint primLocalID, string description) 378 public void PrimDescription(uint primLocalID, string description)
379 { 379 {
380 Primitive prim = null; 380 Primitive prim = null;
381 foreach (EntityBase ent in Entities.Values) 381 foreach (EntityBase ent in Entities.Values)
382 { 382 {
383 if (ent is SceneObject) 383 if (ent is SceneObject)
384 { 384 {
385 prim = ((SceneObject)ent).HasChildPrim(primLocalID); 385 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
386 if (prim != null) 386 if (prim != null)
387 { 387 {
388 prim.Description = description; 388 prim.Description = description;
389 break; 389 break;
390 } 390 }
391 } 391 }
392 } 392 }
393 } 393 }
394 394
395 /// <summary> 395 /// <summary>
396 /// 396 ///
397 /// </summary> 397 /// </summary>
398 /// <param name="primLocalID"></param> 398 /// <param name="primLocalID"></param>
399 /// <param name="description"></param> 399 /// <param name="description"></param>
400 public void PrimName(uint primLocalID, string name) 400 public void PrimName(uint primLocalID, string name)
401 { 401 {
402 Primitive prim = null; 402 Primitive prim = null;
403 foreach (EntityBase ent in Entities.Values) 403 foreach (EntityBase ent in Entities.Values)
404 { 404 {
405 if (ent is SceneObject) 405 if (ent is SceneObject)
406 { 406 {
407 prim = ((SceneObject)ent).HasChildPrim(primLocalID); 407 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
408 if (prim != null) 408 if (prim != null)
409 { 409 {
410 prim.Name = name; 410 prim.Name = name;
411 break; 411 break;
412 } 412 }
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 417 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
418 { 418 {
419 Primitive prim = null; 419 Primitive prim = null;
420 foreach (EntityBase ent in Entities.Values) 420 foreach (EntityBase ent in Entities.Values)
421 { 421 {
422 if (ent is SceneObject) 422 if (ent is SceneObject)
423 { 423 {
424 prim = ((SceneObject)ent).HasChildPrim(objectID); 424 prim = ((SceneObject)ent).HasChildPrim(objectID);
425 if (prim != null) 425 if (prim != null)
426 { 426 {
427 ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); 427 ((SceneObject)ent).GrapMovement(offset, pos, remoteClient);
428 break; 428 break;
429 } 429 }
430 } 430 }
431 } 431 }
432 /* 432 /*
433 if (this.Entities.ContainsKey(objectID)) 433 if (this.Entities.ContainsKey(objectID))
434 { 434 {
435 if (this.Entities[objectID] is SceneObject) 435 if (this.Entities[objectID] is SceneObject)
436 { 436 {
437 ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); 437 ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
438 } 438 }
439 }*/ 439 }*/
440 } 440 }
441 441
442 /// <summary> 442 /// <summary>
443 /// 443 ///
444 /// </summary> 444 /// </summary>
445 /// <param name="localID"></param> 445 /// <param name="localID"></param>
446 /// <param name="packet"></param> 446 /// <param name="packet"></param>
447 /// <param name="remoteClient"></param> 447 /// <param name="remoteClient"></param>
448 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) 448 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
449 { 449 {
450 450
451 } 451 }
452 452
453 /// <summary> 453 /// <summary>
454 /// 454 ///
455 /// </summary> 455 /// </summary>
456 /// <param name="localID"></param> 456 /// <param name="localID"></param>
457 /// <param name="texture"></param> 457 /// <param name="texture"></param>
458 /// <param name="remoteClient"></param> 458 /// <param name="remoteClient"></param>
459 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) 459 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
460 { 460 {
461 Primitive prim = null; 461 Primitive prim = null;
462 foreach (EntityBase ent in Entities.Values) 462 foreach (EntityBase ent in Entities.Values)
463 { 463 {
464 if (ent is SceneObject) 464 if (ent is SceneObject)
465 { 465 {
466 prim = ((SceneObject)ent).HasChildPrim(localID); 466 prim = ((SceneObject)ent).HasChildPrim(localID);
467 if (prim != null) 467 if (prim != null)
468 { 468 {
469 prim.UpdateTextureEntry(texture); 469 prim.UpdateTextureEntry(texture);
470 } 470 }
471 } 471 }
472 } 472 }
473 } 473 }
474 474
475 /// <summary> 475 /// <summary>
476 /// 476 ///
477 /// </summary> 477 /// </summary>
478 /// <param name="localID"></param> 478 /// <param name="localID"></param>
479 /// <param name="pos"></param> 479 /// <param name="pos"></param>
480 /// <param name="remoteClient"></param> 480 /// <param name="remoteClient"></param>
481 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 481 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
482 { 482 {
483 Primitive prim = null; 483 Primitive prim = null;
484 foreach (EntityBase ent in Entities.Values) 484 foreach (EntityBase ent in Entities.Values)
485 { 485 {
486 if (ent is SceneObject) 486 if (ent is SceneObject)
487 { 487 {
488 prim = ((SceneObject)ent).HasChildPrim(localID); 488 prim = ((SceneObject)ent).HasChildPrim(localID);
489 if (prim != null) 489 if (prim != null)
490 { 490 {
491 prim.UpdateGroupPosition(pos); 491 prim.UpdateGroupPosition(pos);
492 break; 492 break;
493 } 493 }
494 } 494 }
495 } 495 }
496 } 496 }
497 497
498 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 498 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
499 { 499 {
500 Primitive prim = null; 500 Primitive prim = null;
501 foreach (EntityBase ent in Entities.Values) 501 foreach (EntityBase ent in Entities.Values)
502 { 502 {
503 if (ent is SceneObject) 503 if (ent is SceneObject)
504 { 504 {
505 prim = ((SceneObject)ent).HasChildPrim(localID); 505 prim = ((SceneObject)ent).HasChildPrim(localID);
506 if (prim != null) 506 if (prim != null)
507 { 507 {
508 prim.UpdateSinglePosition(pos); 508 prim.UpdateSinglePosition(pos);
509 break; 509 break;
510 } 510 }
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 /// <summary> 515 /// <summary>
516 /// 516 ///
517 /// </summary> 517 /// </summary>
518 /// <param name="localID"></param> 518 /// <param name="localID"></param>
519 /// <param name="pos"></param> 519 /// <param name="pos"></param>
520 /// <param name="rot"></param> 520 /// <param name="rot"></param>
521 /// <param name="remoteClient"></param> 521 /// <param name="remoteClient"></param>
522 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) 522 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient)
523 { 523 {
524 Primitive prim = null; 524 Primitive prim = null;
525 foreach (EntityBase ent in Entities.Values) 525 foreach (EntityBase ent in Entities.Values)
526 { 526 {
527 if (ent is SceneObject) 527 if (ent is SceneObject)
528 { 528 {
529 prim = ((SceneObject)ent).HasChildPrim(localID); 529 prim = ((SceneObject)ent).HasChildPrim(localID);
530 if (prim != null) 530 if (prim != null)
531 { 531 {
532 prim.UpdateGroupMouseRotation(pos, rot); 532 prim.UpdateGroupMouseRotation(pos, rot);
533 break; 533 break;
534 } 534 }
535 } 535 }
536 } 536 }
537 } 537 }
538 538
539 /// <summary> 539 /// <summary>
540 /// 540 ///
541 /// </summary> 541 /// </summary>
542 /// <param name="localID"></param> 542 /// <param name="localID"></param>
543 /// <param name="rot"></param> 543 /// <param name="rot"></param>
544 /// <param name="remoteClient"></param> 544 /// <param name="remoteClient"></param>
545 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 545 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
546 { 546 {
547 Primitive prim = null; 547 Primitive prim = null;
548 foreach (EntityBase ent in Entities.Values) 548 foreach (EntityBase ent in Entities.Values)
549 { 549 {
550 if (ent is SceneObject) 550 if (ent is SceneObject)
551 { 551 {
552 prim = ((SceneObject)ent).HasChildPrim(localID); 552 prim = ((SceneObject)ent).HasChildPrim(localID);
553 if (prim != null) 553 if (prim != null)
554 { 554 {
555 prim.UpdateGroupRotation(rot); 555 prim.UpdateGroupRotation(rot);
556 break; 556 break;
557 } 557 }
558 } 558 }
559 } 559 }
560 } 560 }
561 561
562 /// <summary> 562 /// <summary>
563 /// 563 ///
564 /// </summary> 564 /// </summary>
565 /// <param name="localID"></param> 565 /// <param name="localID"></param>
566 /// <param name="rot"></param> 566 /// <param name="rot"></param>
567 /// <param name="remoteClient"></param> 567 /// <param name="remoteClient"></param>
568 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 568 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
569 { 569 {
570 //Console.WriteLine("trying to update single prim rotation"); 570 //Console.WriteLine("trying to update single prim rotation");
571 Primitive prim = null; 571 Primitive prim = null;
572 foreach (EntityBase ent in Entities.Values) 572 foreach (EntityBase ent in Entities.Values)
573 { 573 {
574 if (ent is SceneObject) 574 if (ent is SceneObject)
575 { 575 {
576 prim = ((SceneObject)ent).HasChildPrim(localID); 576 prim = ((SceneObject)ent).HasChildPrim(localID);
577 if (prim != null) 577 if (prim != null)
578 { 578 {
579 prim.UpdateSingleRotation(rot); 579 prim.UpdateSingleRotation(rot);
580 break; 580 break;
581 } 581 }
582 } 582 }
583 } 583 }
584 } 584 }
585 585
586 /// <summary> 586 /// <summary>
587 /// 587 ///
588 /// </summary> 588 /// </summary>
589 /// <param name="localID"></param> 589 /// <param name="localID"></param>
590 /// <param name="scale"></param> 590 /// <param name="scale"></param>
591 /// <param name="remoteClient"></param> 591 /// <param name="remoteClient"></param>
592 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) 592 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
593 { 593 {
594 Primitive prim = null; 594 Primitive prim = null;
595 foreach (EntityBase ent in Entities.Values) 595 foreach (EntityBase ent in Entities.Values)
596 { 596 {
597 if (ent is SceneObject) 597 if (ent is SceneObject)
598 { 598 {
599 prim = ((SceneObject)ent).HasChildPrim(localID); 599 prim = ((SceneObject)ent).HasChildPrim(localID);
600 if (prim != null) 600 if (prim != null)
601 { 601 {
602 prim.ResizeGoup(scale); 602 prim.ResizeGoup(scale);
603 break; 603 break;
604 } 604 }
605 } 605 }
606 } 606 }
607 } 607 }
608 608
609 /// <summary> 609 /// <summary>
610 /// Sends prims to a client 610 /// Sends prims to a client
611 /// </summary> 611 /// </summary>
612 /// <param name="RemoteClient">Client to send to</param> 612 /// <param name="RemoteClient">Client to send to</param>
613 public void GetInitialPrims(IClientAPI RemoteClient) 613 public void GetInitialPrims(IClientAPI RemoteClient)
614 { 614 {
615 615
616 } 616 }
617 } 617 }
618} 618}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 1e69c9e..a06d74d 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1,919 +1,919 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using System.Timers; 31using System.Timers;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Interfaces; 37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types; 39using OpenSim.Framework.Types;
40using OpenSim.Physics.Manager; 40using OpenSim.Physics.Manager;
41using OpenSim.Region.Caches; 41using OpenSim.Region.Caches;
42using OpenSim.Region.Interfaces; 42using OpenSim.Region.Interfaces;
43using OpenSim.Region.Scripting; 43using OpenSim.Region.Scripting;
44using OpenSim.Region.Terrain; 44using OpenSim.Region.Terrain;
45using Caps = OpenSim.Region.Capabilities.Caps; 45using Caps = OpenSim.Region.Capabilities.Caps;
46using Timer = System.Timers.Timer; 46using Timer = System.Timers.Timer;
47 47
48namespace OpenSim.Region.Environment.Scenes 48namespace OpenSim.Region.Environment.Scenes
49{ 49{
50 public delegate bool FilterAvatarList(ScenePresence avatar); 50 public delegate bool FilterAvatarList(ScenePresence avatar);
51 public delegate void ForEachScenePresenceDelegate(ScenePresence presence); 51 public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
52 52
53 public partial class Scene : SceneBase, ILocalStorageReceiver 53 public partial class Scene : SceneBase, ILocalStorageReceiver
54 { 54 {
55 protected Timer m_heartbeatTimer = new Timer(); 55 protected Timer m_heartbeatTimer = new Timer();
56 protected Dictionary<LLUUID, ScenePresence> Avatars; 56 protected Dictionary<LLUUID, ScenePresence> Avatars;
57 protected Dictionary<LLUUID, SceneObject> Prims; 57 protected Dictionary<LLUUID, SceneObject> Prims;
58 protected PhysicsScene phyScene; 58 protected PhysicsScene phyScene;
59 protected float timeStep = 0.1f; 59 protected float timeStep = 0.1f;
60 private Random Rand = new Random(); 60 private Random Rand = new Random();
61 private uint _primCount = 702000; 61 private uint _primCount = 702000;
62 private System.Threading.Mutex _primAllocateMutex = new Mutex(false); 62 private System.Threading.Mutex _primAllocateMutex = new Mutex(false);
63 private int storageCount; 63 private int storageCount;
64 private int parcelPrimCheckCount; 64 private int parcelPrimCheckCount;
65 private Mutex updateLock; 65 private Mutex updateLock;
66 66
67 protected AuthenticateSessionsBase authenticateHandler; 67 protected AuthenticateSessionsBase authenticateHandler;
68 protected RegionCommsListener regionCommsHost; 68 protected RegionCommsListener regionCommsHost;
69 protected CommunicationsManager commsManager; 69 protected CommunicationsManager commsManager;
70 protected StorageManager storageManager; 70 protected StorageManager storageManager;
71 71
72 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); 72 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
73 protected BaseHttpServer httpListener; 73 protected BaseHttpServer httpListener;
74 74
75 #region Properties 75 #region Properties
76 /// <summary> 76 /// <summary>
77 /// 77 ///
78 /// </summary> 78 /// </summary>
79 public PhysicsScene PhysScene 79 public PhysicsScene PhysScene
80 { 80 {
81 set 81 set
82 { 82 {
83 this.phyScene = value; 83 this.phyScene = value;
84 } 84 }
85 get 85 get
86 { 86 {
87 return (this.phyScene); 87 return (this.phyScene);
88 } 88 }
89 } 89 }
90 90
91 private ParcelManager m_parcelManager; 91 private ParcelManager m_parcelManager;
92 public ParcelManager ParcelManager 92 public ParcelManager ParcelManager
93 { 93 {
94 get { return m_parcelManager; } 94 get { return m_parcelManager; }
95 } 95 }
96 96
97 private EstateManager m_estateManager; 97 private EstateManager m_estateManager;
98 public EstateManager EstateManager 98 public EstateManager EstateManager
99 { 99 {
100 get { return m_estateManager; } 100 get { return m_estateManager; }
101 } 101 }
102 102
103 private EventManager m_eventManager; 103 private EventManager m_eventManager;
104 public EventManager EventManager 104 public EventManager EventManager
105 { 105 {
106 get { return m_eventManager; } 106 get { return m_eventManager; }
107 } 107 }
108 108
109 private ScriptManager m_scriptManager; 109 private ScriptManager m_scriptManager;
110 public ScriptManager ScriptManager 110 public ScriptManager ScriptManager
111 { 111 {
112 get { return m_scriptManager; } 112 get { return m_scriptManager; }
113 } 113 }
114 114
115 public Dictionary<LLUUID, SceneObject> Objects 115 public Dictionary<LLUUID, SceneObject> Objects
116 { 116 {
117 get { return Prims; } 117 get { return Prims; }
118 } 118 }
119 119
120 #endregion 120 #endregion
121 121
122 #region Constructors 122 #region Constructors
123 /// <summary> 123 /// <summary>
124 /// Creates a new World class, and a region to go with it. 124 /// Creates a new World class, and a region to go with it.
125 /// </summary> 125 /// </summary>
126 /// <param name="clientThreads">Dictionary to contain client threads</param> 126 /// <param name="clientThreads">Dictionary to contain client threads</param>
127 /// <param name="regionHandle">Region Handle for this region</param> 127 /// <param name="regionHandle">Region Handle for this region</param>
128 /// <param name="regionName">Region Name for this region</param> 128 /// <param name="regionName">Region Name for this region</param>
129 public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) 129 public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
130 { 130 {
131 updateLock = new Mutex(false); 131 updateLock = new Mutex(false);
132 this.authenticateHandler = authen; 132 this.authenticateHandler = authen;
133 this.commsManager = commsMan; 133 this.commsManager = commsMan;
134 this.storageManager = storeManager; 134 this.storageManager = storeManager;
135 this.assetCache = assetCach; 135 this.assetCache = assetCach;
136 m_regInfo = regInfo; 136 m_regInfo = regInfo;
137 m_regionHandle = m_regInfo.RegionHandle; 137 m_regionHandle = m_regInfo.RegionHandle;
138 m_regionName = m_regInfo.RegionName; 138 m_regionName = m_regInfo.RegionName;
139 this.m_datastore = m_regInfo.DataStore; 139 this.m_datastore = m_regInfo.DataStore;
140 this.RegisterRegionWithComms(); 140 this.RegisterRegionWithComms();
141 141
142 m_parcelManager = new ParcelManager(this, this.m_regInfo); 142 m_parcelManager = new ParcelManager(this, this.m_regInfo);
143 m_estateManager = new EstateManager(this, this.m_regInfo); 143 m_estateManager = new EstateManager(this, this.m_regInfo);
144 m_scriptManager = new ScriptManager(this); 144 m_scriptManager = new ScriptManager(this);
145 m_eventManager = new EventManager(); 145 m_eventManager = new EventManager();
146 146
147 m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_parcelManager.addPrimToParcelCounts); 147 m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_parcelManager.addPrimToParcelCounts);
148 148
149 MainLog.Instance.Verbose("World.cs - creating new entitities instance"); 149 MainLog.Instance.Verbose("World.cs - creating new entitities instance");
150 Entities = new Dictionary<LLUUID, EntityBase>(); 150 Entities = new Dictionary<LLUUID, EntityBase>();
151 Avatars = new Dictionary<LLUUID, ScenePresence>(); 151 Avatars = new Dictionary<LLUUID, ScenePresence>();
152 Prims = new Dictionary<LLUUID, SceneObject>(); 152 Prims = new Dictionary<LLUUID, SceneObject>();
153 153
154 MainLog.Instance.Verbose("World.cs - loading objects from datastore"); 154 MainLog.Instance.Verbose("World.cs - loading objects from datastore");
155 List<SceneObject> PrimsFromDB = storageManager.DataStore.LoadObjects(); 155 List<SceneObject> PrimsFromDB = storageManager.DataStore.LoadObjects();
156 foreach (SceneObject prim in PrimsFromDB) 156 foreach (SceneObject prim in PrimsFromDB)
157 { 157 {
158 AddEntity(prim); 158 AddEntity(prim);
159 } 159 }
160 MainLog.Instance.Verbose("World.cs - loaded " + PrimsFromDB.Count.ToString() + " object(s)"); 160 MainLog.Instance.Verbose("World.cs - loaded " + PrimsFromDB.Count.ToString() + " object(s)");
161 161
162 162
163 MainLog.Instance.Verbose("World.cs - creating LandMap"); 163 MainLog.Instance.Verbose("World.cs - creating LandMap");
164 Terrain = new TerrainEngine(); 164 Terrain = new TerrainEngine();
165 165
166 ScenePresence.LoadAnims(); 166 ScenePresence.LoadAnims();
167 167
168 this.httpListener = httpServer; 168 this.httpListener = httpServer;
169 } 169 }
170 #endregion 170 #endregion
171 171
172 #region Script Handling Methods 172 #region Script Handling Methods
173 173
174 public void SendCommandToScripts(string[] args) 174 public void SendCommandToScripts(string[] args)
175 { 175 {
176 m_eventManager.TriggerOnScriptConsole(args); 176 m_eventManager.TriggerOnScriptConsole(args);
177 } 177 }
178 178
179 #endregion 179 #endregion
180 180
181 /// <summary> 181 /// <summary>
182 /// 182 ///
183 /// </summary> 183 /// </summary>
184 public void StartTimer() 184 public void StartTimer()
185 { 185 {
186 m_heartbeatTimer.Enabled = true; 186 m_heartbeatTimer.Enabled = true;
187 m_heartbeatTimer.Interval = 100; 187 m_heartbeatTimer.Interval = 100;
188 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); 188 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
189 } 189 }
190 190
191 191
192 #region Update Methods 192 #region Update Methods
193 193
194 194
195 /// <summary> 195 /// <summary>
196 /// Performs per-frame updates regularly 196 /// Performs per-frame updates regularly
197 /// </summary> 197 /// </summary>
198 /// <param name="sender"></param> 198 /// <param name="sender"></param>
199 /// <param name="e"></param> 199 /// <param name="e"></param>
200 void Heartbeat(object sender, EventArgs e) 200 void Heartbeat(object sender, EventArgs e)
201 { 201 {
202 this.Update(); 202 this.Update();
203 } 203 }
204 204
205 /// <summary> 205 /// <summary>
206 /// Performs per-frame updates on the world, this should be the central world loop 206 /// Performs per-frame updates on the world, this should be the central world loop
207 /// </summary> 207 /// </summary>
208 public override void Update() 208 public override void Update()
209 { 209 {
210 updateLock.WaitOne(); 210 updateLock.WaitOne();
211 try 211 try
212 { 212 {
213 if (this.phyScene.IsThreaded) 213 if (this.phyScene.IsThreaded)
214 { 214 {
215 this.phyScene.GetResults(); 215 this.phyScene.GetResults();
216 216
217 } 217 }
218 218
219 foreach (LLUUID UUID in Entities.Keys) 219 foreach (LLUUID UUID in Entities.Keys)
220 { 220 {
221 Entities[UUID].updateMovement(); 221 Entities[UUID].updateMovement();
222 } 222 }
223 223
224 lock (this.m_syncRoot) 224 lock (this.m_syncRoot)
225 { 225 {
226 this.phyScene.Simulate(timeStep); 226 this.phyScene.Simulate(timeStep);
227 } 227 }
228 228
229 foreach (LLUUID UUID in Entities.Keys) 229 foreach (LLUUID UUID in Entities.Keys)
230 { 230 {
231 Entities[UUID].update(); 231 Entities[UUID].update();
232 } 232 }
233 233
234 // General purpose event manager 234 // General purpose event manager
235 m_eventManager.TriggerOnFrame(); 235 m_eventManager.TriggerOnFrame();
236 236
237 //backup world data 237 //backup world data
238 this.storageCount++; 238 this.storageCount++;
239 if (storageCount > 1200) //set to how often you want to backup 239 if (storageCount > 1200) //set to how often you want to backup
240 { 240 {
241 this.Backup(); 241 this.Backup();
242 storageCount = 0; 242 storageCount = 0;
243 } 243 }
244 244
245 this.parcelPrimCheckCount++; 245 this.parcelPrimCheckCount++;
246 if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims 246 if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims
247 { 247 {
248 if (m_parcelManager.parcelPrimCountTainted) 248 if (m_parcelManager.parcelPrimCountTainted)
249 { 249 {
250 //Perform parcel update of prim count 250 //Perform parcel update of prim count
251 performParcelPrimCountUpdate(); 251 performParcelPrimCountUpdate();
252 this.parcelPrimCheckCount = 0; 252 this.parcelPrimCheckCount = 0;
253 } 253 }
254 } 254 }
255 255
256 } 256 }
257 catch (Exception e) 257 catch (Exception e)
258 { 258 {
259 MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString()); 259 MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
260 } 260 }
261 updateLock.ReleaseMutex(); 261 updateLock.ReleaseMutex();
262 262
263 } 263 }
264 264
265 /// <summary> 265 /// <summary>
266 /// 266 ///
267 /// </summary> 267 /// </summary>
268 /// <returns></returns> 268 /// <returns></returns>
269 public bool Backup() 269 public bool Backup()
270 { 270 {
271 EventManager.TriggerOnBackup(this.storageManager.DataStore); 271 EventManager.TriggerOnBackup(this.storageManager.DataStore);
272 return true; 272 return true;
273 } 273 }
274 #endregion 274 #endregion
275 275
276 #region Regenerate Terrain 276 #region Regenerate Terrain
277 277
278 /// <summary> 278 /// <summary>
279 /// Rebuilds the terrain using a procedural algorithm 279 /// Rebuilds the terrain using a procedural algorithm
280 /// </summary> 280 /// </summary>
281 public void RegenerateTerrain() 281 public void RegenerateTerrain()
282 { 282 {
283 try 283 try
284 { 284 {
285 Terrain.hills(); 285 Terrain.hills();
286 286
287 lock (this.m_syncRoot) 287 lock (this.m_syncRoot)
288 { 288 {
289 this.phyScene.SetTerrain(Terrain.getHeights1D()); 289 this.phyScene.SetTerrain(Terrain.getHeights1D());
290 } 290 }
291 291
292 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); 292 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
293 293
294 this.ForEachScenePresence(delegate(ScenePresence presence) 294 this.ForEachScenePresence(delegate(ScenePresence presence)
295 { 295 {
296 this.SendLayerData(presence.ControllingClient); 296 this.SendLayerData(presence.ControllingClient);
297 }); 297 });
298 298
299 foreach (LLUUID UUID in Entities.Keys) 299 foreach (LLUUID UUID in Entities.Keys)
300 { 300 {
301 Entities[UUID].LandRenegerated(); 301 Entities[UUID].LandRenegerated();
302 } 302 }
303 } 303 }
304 catch (Exception e) 304 catch (Exception e)
305 { 305 {
306 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); 306 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
307 } 307 }
308 } 308 }
309 309
310 /// <summary> 310 /// <summary>
311 /// Rebuilds the terrain using a 2D float array 311 /// Rebuilds the terrain using a 2D float array
312 /// </summary> 312 /// </summary>
313 /// <param name="newMap">256,256 float array containing heights</param> 313 /// <param name="newMap">256,256 float array containing heights</param>
314 public void RegenerateTerrain(float[,] newMap) 314 public void RegenerateTerrain(float[,] newMap)
315 { 315 {
316 try 316 try
317 { 317 {
318 this.Terrain.setHeights2D(newMap); 318 this.Terrain.setHeights2D(newMap);
319 lock (this.m_syncRoot) 319 lock (this.m_syncRoot)
320 { 320 {
321 this.phyScene.SetTerrain(this.Terrain.getHeights1D()); 321 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
322 } 322 }
323 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); 323 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
324 324
325 this.ForEachScenePresence(delegate(ScenePresence presence) 325 this.ForEachScenePresence(delegate(ScenePresence presence)
326 { 326 {
327 this.SendLayerData(presence.ControllingClient); 327 this.SendLayerData(presence.ControllingClient);
328 }); 328 });
329 329
330 foreach (LLUUID UUID in Entities.Keys) 330 foreach (LLUUID UUID in Entities.Keys)
331 { 331 {
332 Entities[UUID].LandRenegerated(); 332 Entities[UUID].LandRenegerated();
333 } 333 }
334 } 334 }
335 catch (Exception e) 335 catch (Exception e)
336 { 336 {
337 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); 337 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
338 } 338 }
339 } 339 }
340 340
341 /// <summary> 341 /// <summary>
342 /// Rebuilds the terrain assuming changes occured at a specified point[?] 342 /// Rebuilds the terrain assuming changes occured at a specified point[?]
343 /// </summary> 343 /// </summary>
344 /// <param name="changes">???</param> 344 /// <param name="changes">???</param>
345 /// <param name="pointx">???</param> 345 /// <param name="pointx">???</param>
346 /// <param name="pointy">???</param> 346 /// <param name="pointy">???</param>
347 public void RegenerateTerrain(bool changes, int pointx, int pointy) 347 public void RegenerateTerrain(bool changes, int pointx, int pointy)
348 { 348 {
349 try 349 try
350 { 350 {
351 if (changes) 351 if (changes)
352 { 352 {
353 /* Dont save here, rely on tainting system instead */ 353 /* Dont save here, rely on tainting system instead */
354 354
355 this.ForEachScenePresence(delegate(ScenePresence presence) 355 this.ForEachScenePresence(delegate(ScenePresence presence)
356 { 356 {
357 this.SendLayerData(pointx, pointy, presence.ControllingClient); 357 this.SendLayerData(pointx, pointy, presence.ControllingClient);
358 }); 358 });
359 } 359 }
360 } 360 }
361 catch (Exception e) 361 catch (Exception e)
362 { 362 {
363 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); 363 MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
364 } 364 }
365 } 365 }
366 366
367 #endregion 367 #endregion
368 368
369 #region Load Terrain 369 #region Load Terrain
370 /// <summary> 370 /// <summary>
371 /// Loads the World heightmap 371 /// Loads the World heightmap
372 /// </summary> 372 /// </summary>
373 /// 373 ///
374 public override void LoadWorldMap() 374 public override void LoadWorldMap()
375 { 375 {
376 try 376 try
377 { 377 {
378 double[,] map = this.storageManager.DataStore.LoadTerrain(); 378 double[,] map = this.storageManager.DataStore.LoadTerrain();
379 if (map == null) 379 if (map == null)
380 { 380 {
381 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) 381 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
382 { 382 {
383 Console.WriteLine("No default terrain, procedurally generating..."); 383 Console.WriteLine("No default terrain, procedurally generating...");
384 this.Terrain.hills(); 384 this.Terrain.hills();
385 385
386 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); 386 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
387 } 387 }
388 else 388 else
389 { 389 {
390 try 390 try
391 { 391 {
392 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile); 392 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile);
393 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier; 393 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier;
394 } 394 }
395 catch 395 catch
396 { 396 {
397 Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); 397 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
398 Terrain.hills(); 398 Terrain.hills();
399 } 399 }
400 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); 400 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
401 } 401 }
402 } 402 }
403 else 403 else
404 { 404 {
405 this.Terrain.setHeights2D(map); 405 this.Terrain.setHeights2D(map);
406 } 406 }
407 407
408 CreateTerrainTexture(); 408 CreateTerrainTexture();
409 409
410 } 410 }
411 catch (Exception e) 411 catch (Exception e)
412 { 412 {
413 MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString()); 413 MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
414 } 414 }
415 } 415 }
416 416
417 /// <summary> 417 /// <summary>
418 /// 418 ///
419 /// </summary> 419 /// </summary>
420 public void CreateTerrainTexture() 420 public void CreateTerrainTexture()
421 { 421 {
422 //create a texture asset of the terrain 422 //create a texture asset of the terrain
423 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png"); 423 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png");
424 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); 424 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
425 AssetBase asset = new AssetBase(); 425 AssetBase asset = new AssetBase();
426 asset.FullID = this.m_regInfo.estateSettings.terrainImageID; 426 asset.FullID = this.m_regInfo.estateSettings.terrainImageID;
427 asset.Data = data; 427 asset.Data = data;
428 asset.Name = "terrainImage"; 428 asset.Name = "terrainImage";
429 asset.Type = 0; 429 asset.Type = 0;
430 this.assetCache.AddAsset(asset); 430 this.assetCache.AddAsset(asset);
431 } 431 }
432 #endregion 432 #endregion
433 433
434 #region Primitives Methods 434 #region Primitives Methods
435 435
436 436
437 /// <summary> 437 /// <summary>
438 /// Loads the World's objects 438 /// Loads the World's objects
439 /// </summary> 439 /// </summary>
440 public void LoadPrimsFromStorage() 440 public void LoadPrimsFromStorage()
441 { 441 {
442 try 442 try
443 { 443 {
444 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); 444 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
445 this.localStorage.LoadPrimitives(this); 445 this.localStorage.LoadPrimitives(this);
446 } 446 }
447 catch (Exception e) 447 catch (Exception e)
448 { 448 {
449 MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); 449 MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
450 } 450 }
451 } 451 }
452 452
453 /// <summary> 453 /// <summary>
454 /// Loads a specific object from storage 454 /// Loads a specific object from storage
455 /// </summary> 455 /// </summary>
456 /// <param name="prim">The object to load</param> 456 /// <param name="prim">The object to load</param>
457 public void PrimFromStorage(PrimData prim) 457 public void PrimFromStorage(PrimData prim)
458 { 458 {
459 } 459 }
460 460
461 /// <summary> 461 /// <summary>
462 /// Returns a new unallocated primitive ID 462 /// Returns a new unallocated primitive ID
463 /// </summary> 463 /// </summary>
464 /// <returns>A brand new primitive ID</returns> 464 /// <returns>A brand new primitive ID</returns>
465 public uint PrimIDAllocate() 465 public uint PrimIDAllocate()
466 { 466 {
467 uint myID; 467 uint myID;
468 468
469 _primAllocateMutex.WaitOne(); 469 _primAllocateMutex.WaitOne();
470 ++_primCount; 470 ++_primCount;
471 myID = _primCount; 471 myID = _primCount;
472 _primAllocateMutex.ReleaseMutex(); 472 _primAllocateMutex.ReleaseMutex();
473 473
474 return myID; 474 return myID;
475 } 475 }
476 476
477 /// <summary> 477 /// <summary>
478 /// 478 ///
479 /// </summary> 479 /// </summary>
480 /// <param name="addPacket"></param> 480 /// <param name="addPacket"></param>
481 /// <param name="ownerID"></param> 481 /// <param name="ownerID"></param>
482 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) 482 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
483 { 483 {
484 484
485 SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape); 485 SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape);
486 AddEntity(sceneOb); 486 AddEntity(sceneOb);
487 } 487 }
488 488
489 public void RemovePrim(uint localID, LLUUID avatar_deleter) 489 public void RemovePrim(uint localID, LLUUID avatar_deleter)
490 { 490 {
491 foreach (EntityBase obj in Entities.Values) 491 foreach (EntityBase obj in Entities.Values)
492 { 492 {
493 if (obj is SceneObject) 493 if (obj is SceneObject)
494 { 494 {
495 if (((SceneObject)obj).LocalId == localID) 495 if (((SceneObject)obj).LocalId == localID)
496 { 496 {
497 RemoveEntity((SceneObject)obj); 497 RemoveEntity((SceneObject)obj);
498 return; 498 return;
499 } 499 }
500 } 500 }
501 } 501 }
502 502
503 } 503 }
504 504
505 public void AddEntity(SceneObject sceneObject) 505 public void AddEntity(SceneObject sceneObject)
506 { 506 {
507 this.Entities.Add(sceneObject.rootUUID, sceneObject); 507 this.Entities.Add(sceneObject.rootUUID, sceneObject);
508 } 508 }
509 509
510 public void RemoveEntity(SceneObject sceneObject) 510 public void RemoveEntity(SceneObject sceneObject)
511 { 511 {
512 if (this.Entities.ContainsKey(sceneObject.rootUUID)) 512 if (this.Entities.ContainsKey(sceneObject.rootUUID))
513 { 513 {
514 m_parcelManager.removePrimFromParcelCounts(sceneObject); 514 m_parcelManager.removePrimFromParcelCounts(sceneObject);
515 this.Entities.Remove(sceneObject.rootUUID); 515 this.Entities.Remove(sceneObject.rootUUID);
516 m_parcelManager.setPrimsTainted(); 516 m_parcelManager.setPrimsTainted();
517 } 517 }
518 } 518 }
519 519
520 /// <summary> 520 /// <summary>
521 /// Called by a prim when it has been created/cloned, so that its events can be subscribed to 521 /// Called by a prim when it has been created/cloned, so that its events can be subscribed to
522 /// </summary> 522 /// </summary>
523 /// <param name="prim"></param> 523 /// <param name="prim"></param>
524 public void AcknowledgeNewPrim(Primitive prim) 524 public void AcknowledgeNewPrim(Primitive prim)
525 { 525 {
526 prim.OnPrimCountTainted += m_parcelManager.setPrimsTainted; 526 prim.OnPrimCountTainted += m_parcelManager.setPrimsTainted;
527 } 527 }
528 #endregion 528 #endregion
529 529
530 #region Add/Remove Avatar Methods 530 #region Add/Remove Avatar Methods
531 531
532 /// <summary> 532 /// <summary>
533 /// 533 ///
534 /// </summary> 534 /// </summary>
535 /// <param name="remoteClient"></param 535 /// <param name="remoteClient"></param
536 /// <param name="agentID"></param> 536 /// <param name="agentID"></param>
537 /// <param name="child"></param> 537 /// <param name="child"></param>
538 public override void AddNewClient(IClientAPI client, bool child) 538 public override void AddNewClient(IClientAPI client, bool child)
539 { 539 {
540 SubscribeToClientEvents(client); 540 SubscribeToClientEvents(client);
541 this.m_estateManager.sendRegionHandshake(client); 541 this.m_estateManager.sendRegionHandshake(client);
542 CreateAndAddScenePresence(client); 542 CreateAndAddScenePresence(client);
543 this.m_parcelManager.sendParcelOverlay(client); 543 this.m_parcelManager.sendParcelOverlay(client);
544 544
545 } 545 }
546 546
547 protected virtual void SubscribeToClientEvents(IClientAPI client) 547 protected virtual void SubscribeToClientEvents(IClientAPI client)
548 { 548 {
549 client.OnRegionHandShakeReply += this.SendLayerData; 549 client.OnRegionHandShakeReply += this.SendLayerData;
550 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); 550 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
551 client.OnChatFromViewer += this.SimChat; 551 client.OnChatFromViewer += this.SimChat;
552 client.OnInstantMessage += this.InstantMessage; 552 client.OnInstantMessage += this.InstantMessage;
553 client.OnRequestWearables += this.InformClientOfNeighbours; 553 client.OnRequestWearables += this.InformClientOfNeighbours;
554 client.OnAddPrim += this.AddNewPrim; 554 client.OnAddPrim += this.AddNewPrim;
555 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; 555 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
556 client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition; 556 client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition;
557 client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation; 557 client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation;
558 client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation; 558 client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation;
559 client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation; 559 client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation;
560 client.OnUpdatePrimScale += this.UpdatePrimScale; 560 client.OnUpdatePrimScale += this.UpdatePrimScale;
561 client.OnUpdatePrimShape += this.UpdatePrimShape; 561 client.OnUpdatePrimShape += this.UpdatePrimShape;
562 client.OnRequestMapBlocks += this.RequestMapBlocks; 562 client.OnRequestMapBlocks += this.RequestMapBlocks;
563 client.OnUpdatePrimTexture += this.UpdatePrimTexture; 563 client.OnUpdatePrimTexture += this.UpdatePrimTexture;
564 client.OnTeleportLocationRequest += this.RequestTeleportLocation; 564 client.OnTeleportLocationRequest += this.RequestTeleportLocation;
565 client.OnObjectSelect += this.SelectPrim; 565 client.OnObjectSelect += this.SelectPrim;
566 client.OnObjectDeselect += this.DeselectPrim; 566 client.OnObjectDeselect += this.DeselectPrim;
567 client.OnGrapUpdate += this.MoveObject; 567 client.OnGrapUpdate += this.MoveObject;
568 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; 568 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
569 client.OnObjectDescription += this.PrimDescription; 569 client.OnObjectDescription += this.PrimDescription;
570 client.OnObjectName += this.PrimName; 570 client.OnObjectName += this.PrimName;
571 client.OnLinkObjects += this.LinkObjects; 571 client.OnLinkObjects += this.LinkObjects;
572 client.OnObjectDuplicate += this.DuplicateObject; 572 client.OnObjectDuplicate += this.DuplicateObject;
573 573
574 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_parcelManager.handleParcelPropertiesRequest); 574 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_parcelManager.handleParcelPropertiesRequest);
575 client.OnParcelDivideRequest += new ParcelDivideRequest(m_parcelManager.handleParcelDivideRequest); 575 client.OnParcelDivideRequest += new ParcelDivideRequest(m_parcelManager.handleParcelDivideRequest);
576 client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest); 576 client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest);
577 client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_parcelManager.handleParcelPropertiesUpdateRequest); 577 client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_parcelManager.handleParcelPropertiesUpdateRequest);
578 client.OnParcelSelectObjects += new ParcelSelectObjects(m_parcelManager.handleParcelSelectObjectsRequest); 578 client.OnParcelSelectObjects += new ParcelSelectObjects(m_parcelManager.handleParcelSelectObjectsRequest);
579 client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_parcelManager.handleParcelObjectOwnersRequest); 579 client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_parcelManager.handleParcelObjectOwnersRequest);
580 580
581 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 581 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
582 582
583 } 583 }
584 584
585 protected ScenePresence CreateAndAddScenePresence(IClientAPI client) 585 protected ScenePresence CreateAndAddScenePresence(IClientAPI client)
586 { 586 {
587 ScenePresence newAvatar = null; 587 ScenePresence newAvatar = null;
588 588
589 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); 589 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
590 newAvatar = new ScenePresence(client, this, this.m_regInfo); 590 newAvatar = new ScenePresence(client, this, this.m_regInfo);
591 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world"); 591 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world");
592 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake "); 592 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake ");
593 593
594 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); 594 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
595 lock (this.m_syncRoot) 595 lock (this.m_syncRoot)
596 { 596 {
597 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); 597 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
598 } 598 }
599 599
600 lock (Entities) 600 lock (Entities)
601 { 601 {
602 if (!Entities.ContainsKey(client.AgentId)) 602 if (!Entities.ContainsKey(client.AgentId))
603 { 603 {
604 this.Entities.Add(client.AgentId, newAvatar); 604 this.Entities.Add(client.AgentId, newAvatar);
605 } 605 }
606 else 606 else
607 { 607 {
608 Entities[client.AgentId] = newAvatar; 608 Entities[client.AgentId] = newAvatar;
609 } 609 }
610 } 610 }
611 lock (Avatars) 611 lock (Avatars)
612 { 612 {
613 if (Avatars.ContainsKey(client.AgentId)) 613 if (Avatars.ContainsKey(client.AgentId))
614 { 614 {
615 Avatars[client.AgentId] = newAvatar; 615 Avatars[client.AgentId] = newAvatar;
616 } 616 }
617 else 617 else
618 { 618 {
619 this.Avatars.Add(client.AgentId, newAvatar); 619 this.Avatars.Add(client.AgentId, newAvatar);
620 } 620 }
621 } 621 }
622 newAvatar.OnSignificantClientMovement += m_parcelManager.handleSignificantClientMovement; 622 newAvatar.OnSignificantClientMovement += m_parcelManager.handleSignificantClientMovement;
623 return newAvatar; 623 return newAvatar;
624 } 624 }
625 625
626 626
627 /// <summary> 627 /// <summary>
628 /// 628 ///
629 /// </summary> 629 /// </summary>
630 /// <param name="agentID"></param> 630 /// <param name="agentID"></param>
631 public override void RemoveClient(LLUUID agentID) 631 public override void RemoveClient(LLUUID agentID)
632 { 632 {
633 m_eventManager.TriggerOnRemovePresence(agentID); 633 m_eventManager.TriggerOnRemovePresence(agentID);
634 634
635 ScenePresence avatar = this.RequestAvatar(agentID); 635 ScenePresence avatar = this.RequestAvatar(agentID);
636 636
637 this.ForEachScenePresence( 637 this.ForEachScenePresence(
638 delegate(ScenePresence presence) 638 delegate(ScenePresence presence)
639 { 639 {
640 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); 640 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
641 }); 641 });
642 642
643 lock (Avatars) 643 lock (Avatars)
644 { 644 {
645 if (Avatars.ContainsKey(agentID)) 645 if (Avatars.ContainsKey(agentID))
646 { 646 {
647 Avatars.Remove(agentID); 647 Avatars.Remove(agentID);
648 } 648 }
649 } 649 }
650 lock (Entities) 650 lock (Entities)
651 { 651 {
652 if (Entities.ContainsKey(agentID)) 652 if (Entities.ContainsKey(agentID))
653 { 653 {
654 Entities.Remove(agentID); 654 Entities.Remove(agentID);
655 } 655 }
656 } 656 }
657 // TODO: Add the removal from physics ? 657 // TODO: Add the removal from physics ?
658 658
659 659
660 660
661 return; 661 return;
662 } 662 }
663 #endregion 663 #endregion
664 664
665 #region Request Avatars List Methods 665 #region Request Avatars List Methods
666 //The idea is to have a group of method that return a list of avatars meeting some requirement 666 //The idea is to have a group of method that return a list of avatars meeting some requirement
667 // ie it could be all Avatars within a certain range of the calling prim/avatar. 667 // ie it could be all Avatars within a certain range of the calling prim/avatar.
668 668
669 /// <summary> 669 /// <summary>
670 /// Request a List of all Avatars in this World 670 /// Request a List of all Avatars in this World
671 /// </summary> 671 /// </summary>
672 /// <returns></returns> 672 /// <returns></returns>
673 public List<ScenePresence> RequestAvatarList() 673 public List<ScenePresence> RequestAvatarList()
674 { 674 {
675 List<ScenePresence> result = new List<ScenePresence>(); 675 List<ScenePresence> result = new List<ScenePresence>();
676 676
677 foreach (ScenePresence avatar in Avatars.Values) 677 foreach (ScenePresence avatar in Avatars.Values)
678 { 678 {
679 result.Add(avatar); 679 result.Add(avatar);
680 } 680 }
681 681
682 return result; 682 return result;
683 } 683 }
684 684
685 /// <summary> 685 /// <summary>
686 /// Request a filtered list of Avatars in this World 686 /// Request a filtered list of Avatars in this World
687 /// </summary> 687 /// </summary>
688 /// <returns></returns> 688 /// <returns></returns>
689 public List<ScenePresence> RequestAvatarList(FilterAvatarList filter) 689 public List<ScenePresence> RequestAvatarList(FilterAvatarList filter)
690 { 690 {
691 List<ScenePresence> result = new List<ScenePresence>(); 691 List<ScenePresence> result = new List<ScenePresence>();
692 692
693 foreach (ScenePresence avatar in Avatars.Values) 693 foreach (ScenePresence avatar in Avatars.Values)
694 { 694 {
695 if (filter(avatar)) 695 if (filter(avatar))
696 { 696 {
697 result.Add(avatar); 697 result.Add(avatar);
698 } 698 }
699 } 699 }
700 700
701 return result; 701 return result;
702 } 702 }
703 703
704 /// <summary> 704 /// <summary>
705 /// Request a Avatar by UUID 705 /// Request a Avatar by UUID
706 /// </summary> 706 /// </summary>
707 /// <param name="avatarID"></param> 707 /// <param name="avatarID"></param>
708 /// <returns></returns> 708 /// <returns></returns>
709 public ScenePresence RequestAvatar(LLUUID avatarID) 709 public ScenePresence RequestAvatar(LLUUID avatarID)
710 { 710 {
711 if (this.Avatars.ContainsKey(avatarID)) 711 if (this.Avatars.ContainsKey(avatarID))
712 { 712 {
713 return Avatars[avatarID]; 713 return Avatars[avatarID];
714 } 714 }
715 return null; 715 return null;
716 } 716 }
717 717
718 public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo) 718 public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo)
719 { 719 {
720 foreach (ScenePresence presence in this.Avatars.Values) 720 foreach (ScenePresence presence in this.Avatars.Values)
721 { 721 {
722 whatToDo(presence); 722 whatToDo(presence);
723 } 723 }
724 } 724 }
725 #endregion 725 #endregion
726 726
727 727
728 /// <summary> 728 /// <summary>
729 /// 729 ///
730 /// </summary> 730 /// </summary>
731 /// <param name="entID"></param> 731 /// <param name="entID"></param>
732 /// <returns></returns> 732 /// <returns></returns>
733 public bool DeleteEntity(LLUUID entID) 733 public bool DeleteEntity(LLUUID entID)
734 { 734 {
735 if (this.Entities.ContainsKey(entID)) 735 if (this.Entities.ContainsKey(entID))
736 { 736 {
737 this.Entities.Remove(entID); 737 this.Entities.Remove(entID);
738 return true; 738 return true;
739 } 739 }
740 return false; 740 return false;
741 } 741 }
742 742
743 public void SendAllSceneObjectsToClient(IClientAPI client) 743 public void SendAllSceneObjectsToClient(IClientAPI client)
744 { 744 {
745 foreach (EntityBase ent in Entities.Values) 745 foreach (EntityBase ent in Entities.Values)
746 { 746 {
747 if (ent is SceneObject) 747 if (ent is SceneObject)
748 { 748 {
749 ((SceneObject)ent).SendAllChildPrimsToClient(client); 749 ((SceneObject)ent).SendAllChildPrimsToClient(client);
750 } 750 }
751 } 751 }
752 } 752 }
753 753
754 #region RegionCommsHost 754 #region RegionCommsHost
755 755
756 /// <summary> 756 /// <summary>
757 /// 757 ///
758 /// </summary> 758 /// </summary>
759 public void RegisterRegionWithComms() 759 public void RegisterRegionWithComms()
760 { 760 {
761 761
762 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo); 762 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo);
763 if (this.regionCommsHost != null) 763 if (this.regionCommsHost != null)
764 { 764 {
765 this.regionCommsHost.OnExpectUser += this.NewUserConnection; 765 this.regionCommsHost.OnExpectUser += this.NewUserConnection;
766 this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing; 766 this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing;
767 } 767 }
768 } 768 }
769 769
770 /// <summary> 770 /// <summary>
771 /// 771 ///
772 /// </summary> 772 /// </summary>
773 /// <param name="regionHandle"></param> 773 /// <param name="regionHandle"></param>
774 /// <param name="agent"></param> 774 /// <param name="agent"></param>
775 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) 775 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
776 { 776 {
777 // Console.WriteLine("World.cs - add new user connection"); 777 // Console.WriteLine("World.cs - add new user connection");
778 //should just check that its meant for this region 778 //should just check that its meant for this region
779 if (regionHandle == this.m_regInfo.RegionHandle) 779 if (regionHandle == this.m_regInfo.RegionHandle)
780 { 780 {
781 if (agent.CapsPath != "") 781 if (agent.CapsPath != "")
782 { 782 {
783 //Console.WriteLine("new user, so creating caps handler for it"); 783 //Console.WriteLine("new user, so creating caps handler for it");
784 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID); 784 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID);
785 cap.RegisterHandlers(); 785 cap.RegisterHandlers();
786 if (capsHandlers.ContainsKey(agent.AgentID)) 786 if (capsHandlers.ContainsKey(agent.AgentID))
787 { 787 {
788 OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated()); 788 OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated());
789 this.capsHandlers[agent.AgentID] = cap; 789 this.capsHandlers[agent.AgentID] = cap;
790 } 790 }
791 else 791 else
792 { 792 {
793 this.capsHandlers.Add(agent.AgentID, cap); 793 this.capsHandlers.Add(agent.AgentID, cap);
794 } 794 }
795 795
796 } 796 }
797 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 797 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
798 } 798 }
799 } 799 }
800 800
801 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 801 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
802 { 802 {
803 if (regionHandle == this.m_regInfo.RegionHandle) 803 if (regionHandle == this.m_regInfo.RegionHandle)
804 { 804 {
805 if (this.Avatars.ContainsKey(agentID)) 805 if (this.Avatars.ContainsKey(agentID))
806 { 806 {
807 this.Avatars[agentID].MakeAvatar(position); 807 this.Avatars[agentID].MakeAvatar(position);
808 } 808 }
809 } 809 }
810 } 810 }
811 811
812 /// <summary> 812 /// <summary>
813 /// 813 ///
814 /// </summary> 814 /// </summary>
815 public void InformClientOfNeighbours(IClientAPI remoteClient) 815 public void InformClientOfNeighbours(IClientAPI remoteClient)
816 { 816 {
817 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); 817 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
818 818
819 if (neighbours != null) 819 if (neighbours != null)
820 { 820 {
821 for (int i = 0; i < neighbours.Count; i++) 821 for (int i = 0; i < neighbours.Count; i++)
822 { 822 {
823 AgentCircuitData agent = remoteClient.RequestClientInfo(); 823 AgentCircuitData agent = remoteClient.RequestClientInfo();
824 agent.BaseFolder = LLUUID.Zero; 824 agent.BaseFolder = LLUUID.Zero;
825 agent.InventoryFolder = LLUUID.Zero; 825 agent.InventoryFolder = LLUUID.Zero;
826 agent.startpos = new LLVector3(128, 128, 70); 826 agent.startpos = new LLVector3(128, 128, 70);
827 agent.child = true; 827 agent.child = true;
828 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); 828 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
829 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint); 829 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint);
830 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); 830 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
831 } 831 }
832 } 832 }
833 } 833 }
834 834
835 /// <summary> 835 /// <summary>
836 /// 836 ///
837 /// </summary> 837 /// </summary>
838 /// <param name="regionHandle"></param> 838 /// <param name="regionHandle"></param>
839 /// <returns></returns> 839 /// <returns></returns>
840 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) 840 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
841 { 841 {
842 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); 842 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle);
843 } 843 }
844 844
845 /// <summary> 845 /// <summary>
846 /// 846 ///
847 /// </summary> 847 /// </summary>
848 /// <param name="minX"></param> 848 /// <param name="minX"></param>
849 /// <param name="minY"></param> 849 /// <param name="minY"></param>
850 /// <param name="maxX"></param> 850 /// <param name="maxX"></param>
851 /// <param name="maxY"></param> 851 /// <param name="maxY"></param>
852 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) 852 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
853 { 853 {
854 List<MapBlockData> mapBlocks; 854 List<MapBlockData> mapBlocks;
855 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 855 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
856 remoteClient.SendMapBlock(mapBlocks); 856 remoteClient.SendMapBlock(mapBlocks);
857 } 857 }
858 858
859 /// <summary> 859 /// <summary>
860 /// 860 ///
861 /// </summary> 861 /// </summary>
862 /// <param name="remoteClient"></param> 862 /// <param name="remoteClient"></param>
863 /// <param name="RegionHandle"></param> 863 /// <param name="RegionHandle"></param>
864 /// <param name="position"></param> 864 /// <param name="position"></param>
865 /// <param name="lookAt"></param> 865 /// <param name="lookAt"></param>
866 /// <param name="flags"></param> 866 /// <param name="flags"></param>
867 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) 867 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
868 { 868 {
869 if (regionHandle == this.m_regionHandle) 869 if (regionHandle == this.m_regionHandle)
870 { 870 {
871 if (this.Avatars.ContainsKey(remoteClient.AgentId)) 871 if (this.Avatars.ContainsKey(remoteClient.AgentId))
872 { 872 {
873 remoteClient.SendTeleportLocationStart(); 873 remoteClient.SendTeleportLocationStart();
874 remoteClient.SendLocalTeleport(position, lookAt, flags); 874 remoteClient.SendLocalTeleport(position, lookAt, flags);
875 this.Avatars[remoteClient.AgentId].Teleport(position); 875 this.Avatars[remoteClient.AgentId].Teleport(position);
876 } 876 }
877 } 877 }
878 else 878 else
879 { 879 {
880 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle); 880 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle);
881 if (reg != null) 881 if (reg != null)
882 { 882 {
883 remoteClient.SendTeleportLocationStart(); 883 remoteClient.SendTeleportLocationStart();
884 AgentCircuitData agent = remoteClient.RequestClientInfo(); 884 AgentCircuitData agent = remoteClient.RequestClientInfo();
885 agent.BaseFolder = LLUUID.Zero; 885 agent.BaseFolder = LLUUID.Zero;
886 agent.InventoryFolder = LLUUID.Zero; 886 agent.InventoryFolder = LLUUID.Zero;
887 agent.startpos = new LLVector3(128, 128, 70); 887 agent.startpos = new LLVector3(128, 128, 70);
888 agent.child = true; 888 agent.child = true;
889 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 889 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
890 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); 890 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
891 891
892 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); 892 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4));
893 893
894 } 894 }
895 } 895 }
896 } 896 }
897 897
898 /// <summary> 898 /// <summary>
899 /// 899 ///
900 /// </summary> 900 /// </summary>
901 /// <param name="regionhandle"></param> 901 /// <param name="regionhandle"></param>
902 /// <param name="agentID"></param> 902 /// <param name="agentID"></param>
903 /// <param name="position"></param> 903 /// <param name="position"></param>
904 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) 904 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
905 { 905 {
906 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); 906 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
907 } 907 }
908 908
909 public void performParcelPrimCountUpdate() 909 public void performParcelPrimCountUpdate()
910 { 910 {
911 m_parcelManager.resetAllParcelPrimCounts(); 911 m_parcelManager.resetAllParcelPrimCounts();
912 m_eventManager.TriggerParcelPrimCountUpdate(); 912 m_eventManager.TriggerParcelPrimCountUpdate();
913 m_parcelManager.finalizeParcelPrimCountUpdate(); 913 m_parcelManager.finalizeParcelPrimCountUpdate();
914 m_parcelManager.parcelPrimCountTainted = false; 914 m_parcelManager.parcelPrimCountTainted = false;
915 } 915 }
916 #endregion 916 #endregion
917 917
918 } 918 }
919} 919}
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 161a5cf..cbf69ac 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -1,195 +1,195 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using libsecondlife; 31using libsecondlife;
32using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
33using OpenSim.Framework.Interfaces; 33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using OpenSim.Region.Caches; 35using OpenSim.Region.Caches;
36using OpenSim.Region.Terrain; 36using OpenSim.Region.Terrain;
37using OpenSim.Framework; 37using OpenSim.Framework;
38 38
39namespace OpenSim.Region.Environment.Scenes 39namespace OpenSim.Region.Environment.Scenes
40{ 40{
41 public abstract class SceneBase : IWorld 41 public abstract class SceneBase : IWorld
42 { 42 {
43 public Dictionary<LLUUID, EntityBase> Entities; 43 public Dictionary<LLUUID, EntityBase> Entities;
44 protected ulong m_regionHandle; 44 protected ulong m_regionHandle;
45 protected string m_regionName; 45 protected string m_regionName;
46 protected RegionInfo m_regInfo; 46 protected RegionInfo m_regInfo;
47 47
48 public TerrainEngine Terrain; 48 public TerrainEngine Terrain;
49 49
50 public string m_datastore; 50 public string m_datastore;
51 public ILocalStorage localStorage; 51 public ILocalStorage localStorage;
52 52
53 protected object m_syncRoot = new object(); 53 protected object m_syncRoot = new object();
54 private uint m_nextLocalId = 8880000; 54 private uint m_nextLocalId = 8880000;
55 protected AssetCache assetCache; 55 protected AssetCache assetCache;
56 56
57 #region Update Methods 57 #region Update Methods
58 /// <summary> 58 /// <summary>
59 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) 59 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
60 /// </summary> 60 /// </summary>
61 public abstract void Update(); 61 public abstract void Update();
62 62
63 #endregion 63 #endregion
64 64
65 #region Terrain Methods 65 #region Terrain Methods
66 66
67 /// <summary> 67 /// <summary>
68 /// Loads the World heightmap 68 /// Loads the World heightmap
69 /// </summary> 69 /// </summary>
70 public abstract void LoadWorldMap(); 70 public abstract void LoadWorldMap();
71 71
72 /// <summary> 72 /// <summary>
73 /// Loads a new storage subsystem from a named library 73 /// Loads a new storage subsystem from a named library
74 /// </summary> 74 /// </summary>
75 /// <param name="dllName">Storage Library</param> 75 /// <param name="dllName">Storage Library</param>
76 /// <returns>Successful or not</returns> 76 /// <returns>Successful or not</returns>
77 public bool LoadStorageDLL(string dllName) 77 public bool LoadStorageDLL(string dllName)
78 { 78 {
79 try 79 try
80 { 80 {
81 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 81 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
82 ILocalStorage store = null; 82 ILocalStorage store = null;
83 83
84 foreach (Type pluginType in pluginAssembly.GetTypes()) 84 foreach (Type pluginType in pluginAssembly.GetTypes())
85 { 85 {
86 if (pluginType.IsPublic) 86 if (pluginType.IsPublic)
87 { 87 {
88 if (!pluginType.IsAbstract) 88 if (!pluginType.IsAbstract)
89 { 89 {
90 Type typeInterface = pluginType.GetInterface("ILocalStorage", true); 90 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
91 91
92 if (typeInterface != null) 92 if (typeInterface != null)
93 { 93 {
94 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 94 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
95 store = plug; 95 store = plug;
96 96
97 store.Initialise(this.m_datastore); 97 store.Initialise(this.m_datastore);
98 break; 98 break;
99 } 99 }
100 100
101 typeInterface = null; 101 typeInterface = null;
102 } 102 }
103 } 103 }
104 } 104 }
105 pluginAssembly = null; 105 pluginAssembly = null;
106 this.localStorage = store; 106 this.localStorage = store;
107 return (store == null); 107 return (store == null);
108 } 108 }
109 catch (Exception e) 109 catch (Exception e)
110 { 110 {
111 MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); 111 MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
112 return false; 112 return false;
113 } 113 }
114 } 114 }
115 115
116 116
117 /// <summary> 117 /// <summary>
118 /// Send the region heightmap to the client 118 /// Send the region heightmap to the client
119 /// </summary> 119 /// </summary>
120 /// <param name="RemoteClient">Client to send to</param> 120 /// <param name="RemoteClient">Client to send to</param>
121 public virtual void SendLayerData(IClientAPI RemoteClient) 121 public virtual void SendLayerData(IClientAPI RemoteClient)
122 { 122 {
123 RemoteClient.SendLayerData(Terrain.getHeights1D()); 123 RemoteClient.SendLayerData(Terrain.getHeights1D());
124 } 124 }
125 125
126 /// <summary> 126 /// <summary>
127 /// Sends a specified patch to a client 127 /// Sends a specified patch to a client
128 /// </summary> 128 /// </summary>
129 /// <param name="px">Patch coordinate (x) 0..16</param> 129 /// <param name="px">Patch coordinate (x) 0..16</param>
130 /// <param name="py">Patch coordinate (y) 0..16</param> 130 /// <param name="py">Patch coordinate (y) 0..16</param>
131 /// <param name="RemoteClient">The client to send to</param> 131 /// <param name="RemoteClient">The client to send to</param>
132 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) 132 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient)
133 { 133 {
134 RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); 134 RemoteClient.SendLayerData(px, py, Terrain.getHeights1D());
135 } 135 }
136 136
137 #endregion 137 #endregion
138 138
139 #region Add/Remove Agent/Avatar 139 #region Add/Remove Agent/Avatar
140 /// <summary> 140 /// <summary>
141 /// 141 ///
142 /// </summary> 142 /// </summary>
143 /// <param name="remoteClient"></param> 143 /// <param name="remoteClient"></param>
144 /// <param name="agentID"></param> 144 /// <param name="agentID"></param>
145 /// <param name="child"></param> 145 /// <param name="child"></param>
146 public abstract void AddNewClient(IClientAPI client, bool child); 146 public abstract void AddNewClient(IClientAPI client, bool child);
147 147
148 /// <summary> 148 /// <summary>
149 /// 149 ///
150 /// </summary> 150 /// </summary>
151 /// <param name="agentID"></param> 151 /// <param name="agentID"></param>
152 public abstract void RemoveClient(LLUUID agentID); 152 public abstract void RemoveClient(LLUUID agentID);
153 153
154 #endregion 154 #endregion
155 155
156 /// <summary> 156 /// <summary>
157 /// 157 ///
158 /// </summary> 158 /// </summary>
159 /// <returns></returns> 159 /// <returns></returns>
160 public virtual RegionInfo RegionInfo 160 public virtual RegionInfo RegionInfo
161 { 161 {
162 get { return this.m_regInfo; } 162 get { return this.m_regInfo; }
163 } 163 }
164 164
165 public object SyncRoot 165 public object SyncRoot
166 { 166 {
167 get { return m_syncRoot; } 167 get { return m_syncRoot; }
168 } 168 }
169 169
170 public uint NextLocalId 170 public uint NextLocalId
171 { 171 {
172 get { return m_nextLocalId++; } 172 get { return m_nextLocalId++; }
173 } 173 }
174 174
175 #region Shutdown 175 #region Shutdown
176 /// <summary> 176 /// <summary>
177 /// Tidy before shutdown 177 /// Tidy before shutdown
178 /// </summary> 178 /// </summary>
179 public virtual void Close() 179 public virtual void Close()
180 { 180 {
181 try 181 try
182 { 182 {
183 this.localStorage.ShutDown(); 183 this.localStorage.ShutDown();
184 } 184 }
185 catch (Exception e) 185 catch (Exception e)
186 { 186 {
187 MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); 187 MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
188 } 188 }
189 } 189 }
190 190
191 #endregion 191 #endregion
192 192
193 193
194 } 194 }
195} 195}
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 1e4b163..255cbf2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -1,82 +1,82 @@
1using libsecondlife; 1using libsecondlife;
2 2
3namespace OpenSim.Region.Environment.Scenes 3namespace OpenSim.Region.Environment.Scenes
4{ 4{
5 /// <summary> 5 /// <summary>
6 /// A class for triggering remote scene events. 6 /// A class for triggering remote scene events.
7 /// </summary> 7 /// </summary>
8 public class EventManager 8 public class EventManager
9 { 9 {
10 public delegate void OnFrameDelegate(); 10 public delegate void OnFrameDelegate();
11 public event OnFrameDelegate OnFrame; 11 public event OnFrameDelegate OnFrame;
12 12
13 public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); 13 public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore);
14 public event OnBackupDelegate OnBackup; 14 public event OnBackupDelegate OnBackup;
15 15
16 public delegate void OnNewPresenceDelegate(ScenePresence presence); 16 public delegate void OnNewPresenceDelegate(ScenePresence presence);
17 public event OnNewPresenceDelegate OnNewPresence; 17 public event OnNewPresenceDelegate OnNewPresence;
18 18
19 public delegate void OnRemovePresenceDelegate(LLUUID uuid); 19 public delegate void OnRemovePresenceDelegate(LLUUID uuid);
20 public event OnRemovePresenceDelegate OnRemovePresence; 20 public event OnRemovePresenceDelegate OnRemovePresence;
21 21
22 public delegate void OnParcelPrimCountUpdateDelegate(); 22 public delegate void OnParcelPrimCountUpdateDelegate();
23 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; 23 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate;
24 24
25 public delegate void OnParcelPrimCountAddDelegate(SceneObject obj); 25 public delegate void OnParcelPrimCountAddDelegate(SceneObject obj);
26 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; 26 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd;
27 27
28 public delegate void OnScriptConsoleDelegate(string[] args); 28 public delegate void OnScriptConsoleDelegate(string[] args);
29 public event OnScriptConsoleDelegate OnScriptConsole; 29 public event OnScriptConsoleDelegate OnScriptConsole;
30 30
31 public void TriggerOnScriptConsole(string[] args) 31 public void TriggerOnScriptConsole(string[] args)
32 { 32 {
33 if (OnScriptConsole != null) 33 if (OnScriptConsole != null)
34 OnScriptConsole(args); 34 OnScriptConsole(args);
35 } 35 }
36 36
37 public void TriggerOnFrame() 37 public void TriggerOnFrame()
38 { 38 {
39 if (OnFrame != null) 39 if (OnFrame != null)
40 { 40 {
41 OnFrame(); 41 OnFrame();
42 } 42 }
43 } 43 }
44 44
45 public void TriggerOnNewPresence(ScenePresence presence) 45 public void TriggerOnNewPresence(ScenePresence presence)
46 { 46 {
47 if (OnNewPresence != null) 47 if (OnNewPresence != null)
48 OnNewPresence(presence); 48 OnNewPresence(presence);
49 } 49 }
50 50
51 public void TriggerOnRemovePresence(LLUUID uuid) 51 public void TriggerOnRemovePresence(LLUUID uuid)
52 { 52 {
53 if (OnRemovePresence != null) 53 if (OnRemovePresence != null)
54 { 54 {
55 OnRemovePresence(uuid); 55 OnRemovePresence(uuid);
56 } 56 }
57 } 57 }
58 58
59 public void TriggerOnBackup(Interfaces.IRegionDataStore dstore) 59 public void TriggerOnBackup(Interfaces.IRegionDataStore dstore)
60 { 60 {
61 if (OnBackup != null) 61 if (OnBackup != null)
62 { 62 {
63 OnBackup(dstore); 63 OnBackup(dstore);
64 } 64 }
65 } 65 }
66 66
67 public void TriggerParcelPrimCountUpdate() 67 public void TriggerParcelPrimCountUpdate()
68 { 68 {
69 if (OnParcelPrimCountUpdate != null) 69 if (OnParcelPrimCountUpdate != null)
70 { 70 {
71 OnParcelPrimCountUpdate(); 71 OnParcelPrimCountUpdate();
72 } 72 }
73 } 73 }
74 public void TriggerParcelPrimCountAdd(SceneObject obj) 74 public void TriggerParcelPrimCountAdd(SceneObject obj)
75 { 75 {
76 if (OnParcelPrimCountAdd != null) 76 if (OnParcelPrimCountAdd != null)
77 { 77 {
78 OnParcelPrimCountAdd(obj); 78 OnParcelPrimCountAdd(obj);
79 } 79 }
80 } 80 }
81 } 81 }
82} 82}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
index e615599..43d41e6 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObject.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -1,309 +1,309 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34using OpenSim.Physics.Manager; 34using OpenSim.Physics.Manager;
35 35
36namespace OpenSim.Region.Environment.Scenes 36namespace OpenSim.Region.Environment.Scenes
37{ 37{
38 public class SceneObject : EntityBase 38 public class SceneObject : EntityBase
39 { 39 {
40 private Encoding enc = Encoding.ASCII; 40 private Encoding enc = Encoding.ASCII;
41 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group 41 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group
42 public Primitive rootPrimitive; 42 public Primitive rootPrimitive;
43 private new Scene m_world; 43 private new Scene m_world;
44 protected ulong m_regionHandle; 44 protected ulong m_regionHandle;
45 45
46 private bool physicsEnabled = false; 46 private bool physicsEnabled = false;
47 private PhysicsScene m_PhysScene; 47 private PhysicsScene m_PhysScene;
48 private PhysicsActor m_PhysActor; 48 private PhysicsActor m_PhysActor;
49 49
50 private EventManager m_eventManager; 50 private EventManager m_eventManager;
51 51
52 public bool isSelected = false; 52 public bool isSelected = false;
53 53
54 public LLUUID rootUUID 54 public LLUUID rootUUID
55 { 55 {
56 get 56 get
57 { 57 {
58 this.uuid = this.rootPrimitive.uuid; 58 this.uuid = this.rootPrimitive.uuid;
59 return this.uuid; 59 return this.uuid;
60 } 60 }
61 } 61 }
62 62
63 public uint rootLocalID 63 public uint rootLocalID
64 { 64 {
65 get 65 get
66 { 66 {
67 this.m_localId = this.rootPrimitive.LocalId; 67 this.m_localId = this.rootPrimitive.LocalId;
68 return this.LocalId; 68 return this.LocalId;
69 } 69 }
70 } 70 }
71 71
72 public int primCount 72 public int primCount
73 { 73 {
74 get 74 get
75 { 75 {
76 return this.ChildPrimitives.Count; 76 return this.ChildPrimitives.Count;
77 } 77 }
78 } 78 }
79 79
80 public Dictionary<LLUUID, Primitive> Children 80 public Dictionary<LLUUID, Primitive> Children
81 { 81 {
82 get 82 get
83 { 83 {
84 return this.ChildPrimitives; 84 return this.ChildPrimitives;
85 } 85 }
86 } 86 }
87 87
88 /// <summary> 88 /// <summary>
89 /// 89 ///
90 /// </summary> 90 /// </summary>
91 public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) 91 public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
92 { 92 {
93 m_regionHandle = world.RegionInfo.RegionHandle; 93 m_regionHandle = world.RegionInfo.RegionHandle;
94 m_world = world; 94 m_world = world;
95 m_eventManager = eventManager; 95 m_eventManager = eventManager;
96 96
97 this.Pos = pos; 97 this.Pos = pos;
98 this.CreateRootFromShape(ownerID, localID, shape, pos); 98 this.CreateRootFromShape(ownerID, localID, shape, pos);
99 99
100 registerEvents(); 100 registerEvents();
101 101
102 } 102 }
103 103
104 /// <summary> 104 /// <summary>
105 /// 105 ///
106 /// </summary> 106 /// </summary>
107 /// <remarks>Need a null constructor for duplication</remarks> 107 /// <remarks>Need a null constructor for duplication</remarks>
108 public SceneObject() 108 public SceneObject()
109 { 109 {
110 110
111 } 111 }
112 112
113 public void registerEvents() 113 public void registerEvents()
114 { 114 {
115 m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); 115 m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup);
116 m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); 116 m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate);
117 } 117 }
118 118
119 public void unregisterEvents() 119 public void unregisterEvents()
120 { 120 {
121 m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); 121 m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup);
122 m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); 122 m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate);
123 } 123 }
124 124
125 /// <summary> 125 /// <summary>
126 /// Processes backup 126 /// Processes backup
127 /// </summary> 127 /// </summary>
128 /// <param name="datastore"></param> 128 /// <param name="datastore"></param>
129 public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) 129 public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
130 { 130 {
131 datastore.StoreObject(this); 131 datastore.StoreObject(this);
132 } 132 }
133 133
134 /// <summary> 134 /// <summary>
135 /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! 135 /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims!
136 /// </summary> 136 /// </summary>
137 private void ProcessParcelPrimCountUpdate() 137 private void ProcessParcelPrimCountUpdate()
138 { 138 {
139 139
140 m_eventManager.TriggerParcelPrimCountAdd(this); 140 m_eventManager.TriggerParcelPrimCountAdd(this);
141 } 141 }
142 142
143 /// <summary> 143 /// <summary>
144 /// 144 ///
145 /// </summary> 145 /// </summary>
146 /// <param name="addPacket"></param> 146 /// <param name="addPacket"></param>
147 /// <param name="agentID"></param> 147 /// <param name="agentID"></param>
148 /// <param name="localID"></param> 148 /// <param name="localID"></param>
149 public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) 149 public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos)
150 { 150 {
151 151
152 this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); 152 this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos);
153 153
154 this.children.Add(rootPrimitive); 154 this.children.Add(rootPrimitive);
155 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); 155 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
156 } 156 }
157 157
158 /// <summary> 158 /// <summary>
159 /// 159 ///
160 /// </summary> 160 /// </summary>
161 /// <param name="data"></param> 161 /// <param name="data"></param>
162 public void CreateFromBytes(byte[] data) 162 public void CreateFromBytes(byte[] data)
163 { 163 {
164 164
165 } 165 }
166 166
167 /// <summary> 167 /// <summary>
168 /// Makes a copy of this SceneObject (and child primitives) 168 /// Makes a copy of this SceneObject (and child primitives)
169 /// </summary> 169 /// </summary>
170 /// <returns>A complete copy of the object</returns> 170 /// <returns>A complete copy of the object</returns>
171 public new SceneObject Copy() 171 public new SceneObject Copy()
172 { 172 {
173 SceneObject dupe = new SceneObject(); 173 SceneObject dupe = new SceneObject();
174 174
175 dupe.m_world = this.m_world; 175 dupe.m_world = this.m_world;
176 dupe.m_eventManager = this.m_eventManager; 176 dupe.m_eventManager = this.m_eventManager;
177 dupe.m_regionHandle = this.m_regionHandle; 177 dupe.m_regionHandle = this.m_regionHandle;
178 Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); 178 Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe);
179 dupe.rootPrimitive = newRoot; 179 dupe.rootPrimitive = newRoot;
180 dupe.children.Add(dupe.rootPrimitive); 180 dupe.children.Add(dupe.rootPrimitive);
181 dupe.rootPrimitive.Pos = this.Pos; 181 dupe.rootPrimitive.Pos = this.Pos;
182 dupe.Rotation = this.Rotation; 182 dupe.Rotation = this.Rotation;
183 dupe.LocalId = m_world.PrimIDAllocate(); 183 dupe.LocalId = m_world.PrimIDAllocate();
184 184
185 dupe.registerEvents(); 185 dupe.registerEvents();
186 return dupe; 186 return dupe;
187 } 187 }
188 188
189 /// <summary> 189 /// <summary>
190 /// 190 ///
191 /// </summary> 191 /// </summary>
192 public void DeleteAllChildren() 192 public void DeleteAllChildren()
193 { 193 {
194 this.children.Clear(); 194 this.children.Clear();
195 this.ChildPrimitives.Clear(); 195 this.ChildPrimitives.Clear();
196 this.rootPrimitive = null; 196 this.rootPrimitive = null;
197 unregisterEvents(); 197 unregisterEvents();
198 } 198 }
199 199
200 /// <summary> 200 /// <summary>
201 /// 201 ///
202 /// </summary> 202 /// </summary>
203 /// <param name="primObject"></param> 203 /// <param name="primObject"></param>
204 public void AddNewChildPrims(SceneObject primObject) 204 public void AddNewChildPrims(SceneObject primObject)
205 { 205 {
206 this.rootPrimitive.AddNewChildren(primObject); 206 this.rootPrimitive.AddNewChildren(primObject);
207 } 207 }
208 208
209 public void AddChildToList(Primitive prim) 209 public void AddChildToList(Primitive prim)
210 { 210 {
211 if (!this.ChildPrimitives.ContainsKey(prim.uuid)) 211 if (!this.ChildPrimitives.ContainsKey(prim.uuid))
212 { 212 {
213 this.ChildPrimitives.Add(prim.uuid, prim); 213 this.ChildPrimitives.Add(prim.uuid, prim);
214 } 214 }
215 } 215 }
216 /// <summary> 216 /// <summary>
217 /// 217 ///
218 /// </summary> 218 /// </summary>
219 /// <param name="primID"></param> 219 /// <param name="primID"></param>
220 /// <returns></returns> 220 /// <returns></returns>
221 public Primitive HasChildPrim(LLUUID primID) 221 public Primitive HasChildPrim(LLUUID primID)
222 { 222 {
223 if (this.ChildPrimitives.ContainsKey(primID)) 223 if (this.ChildPrimitives.ContainsKey(primID))
224 { 224 {
225 return this.ChildPrimitives[primID]; 225 return this.ChildPrimitives[primID];
226 } 226 }
227 227
228 return null; 228 return null;
229 } 229 }
230 230
231 /// <summary> 231 /// <summary>
232 /// 232 ///
233 /// </summary> 233 /// </summary>
234 /// <param name="localID"></param> 234 /// <param name="localID"></param>
235 /// <returns></returns> 235 /// <returns></returns>
236 public Primitive HasChildPrim(uint localID) 236 public Primitive HasChildPrim(uint localID)
237 { 237 {
238 Primitive returnPrim = null; 238 Primitive returnPrim = null;
239 foreach (Primitive prim in this.ChildPrimitives.Values) 239 foreach (Primitive prim in this.ChildPrimitives.Values)
240 { 240 {
241 if (prim.LocalId == localID) 241 if (prim.LocalId == localID)
242 { 242 {
243 returnPrim = prim; 243 returnPrim = prim;
244 break; 244 break;
245 } 245 }
246 } 246 }
247 return returnPrim; 247 return returnPrim;
248 } 248 }
249 249
250 public void SendAllChildPrimsToClient(IClientAPI client) 250 public void SendAllChildPrimsToClient(IClientAPI client)
251 { 251 {
252 this.rootPrimitive.SendFullUpdateForAllChildren(client); 252 this.rootPrimitive.SendFullUpdateForAllChildren(client);
253 } 253 }
254 254
255 /// <summary> 255 /// <summary>
256 /// 256 ///
257 /// </summary> 257 /// </summary>
258 public override void BackUp() 258 public override void BackUp()
259 { 259 {
260 260
261 } 261 }
262 262
263 /// <summary> 263 /// <summary>
264 /// 264 ///
265 /// </summary> 265 /// </summary>
266 /// <param name="offset"></param> 266 /// <param name="offset"></param>
267 /// <param name="pos"></param> 267 /// <param name="pos"></param>
268 /// <param name="remoteClient"></param> 268 /// <param name="remoteClient"></param>
269 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 269 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
270 { 270 {
271 this.rootPrimitive.Pos = pos; 271 this.rootPrimitive.Pos = pos;
272 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); 272 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient);
273 } 273 }
274 274
275 /// <summary> 275 /// <summary>
276 /// 276 ///
277 /// </summary> 277 /// </summary>
278 /// <param name="client"></param> 278 /// <param name="client"></param>
279 public void GetProperites(IClientAPI client) 279 public void GetProperites(IClientAPI client)
280 { 280 {
281 ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); 281 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
282 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 282 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
283 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); 283 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
284 proper.ObjectData[0].ItemID = LLUUID.Zero; 284 proper.ObjectData[0].ItemID = LLUUID.Zero;
285 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; 285 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate;
286 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; 286 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID;
287 proper.ObjectData[0].FolderID = LLUUID.Zero; 287 proper.ObjectData[0].FolderID = LLUUID.Zero;
288 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 288 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
289 proper.ObjectData[0].GroupID = LLUUID.Zero; 289 proper.ObjectData[0].GroupID = LLUUID.Zero;
290 proper.ObjectData[0].InventorySerial = 0; 290 proper.ObjectData[0].InventorySerial = 0;
291 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; 291 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID;
292 proper.ObjectData[0].ObjectID = this.rootUUID; 292 proper.ObjectData[0].ObjectID = this.rootUUID;
293 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; 293 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID;
294 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); 294 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0");
295 proper.ObjectData[0].TextureID = new byte[0]; 295 proper.ObjectData[0].TextureID = new byte[0];
296 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); 296 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0");
297 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); 297 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0");
298 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); 298 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0");
299 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; 299 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;
300 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; 300 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask;
301 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; 301 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;
302 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; 302 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask;
303 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; 303 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask;
304 304
305 client.OutPacket(proper); 305 client.OutPacket(proper);
306 } 306 }
307 307
308 } 308 }
309} 309}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
index d1f75ed..e88ee71 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs
@@ -1,74 +1,74 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Xml; 29using System.Xml;
30using libsecondlife; 30using libsecondlife;
31 31
32namespace OpenSim.Region.Environment.Scenes 32namespace OpenSim.Region.Environment.Scenes
33{ 33{
34 partial class ScenePresence 34 partial class ScenePresence
35 { 35 {
36 public class AvatarAnimations 36 public class AvatarAnimations
37 { 37 {
38 38
39 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); 39 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
40 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); 40 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
41 41
42 public AvatarAnimations() 42 public AvatarAnimations()
43 { 43 {
44 } 44 }
45 45
46 public void LoadAnims() 46 public void LoadAnims()
47 { 47 {
48 //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); 48 //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations");
49 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"); 49 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml");
50 50
51 XmlDocument doc = new XmlDocument(); 51 XmlDocument doc = new XmlDocument();
52 doc.Load(reader); 52 doc.Load(reader);
53 foreach (XmlNode nod in doc.DocumentElement.ChildNodes) 53 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
54 { 54 {
55 55
56 if (nod.Attributes["name"] != null) 56 if (nod.Attributes["name"] != null)
57 { 57 {
58 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); 58 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
59 } 59 }
60 60
61 } 61 }
62 62
63 reader.Close(); 63 reader.Close();
64 64
65 // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); 65 // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
66 66
67 foreach (KeyValuePair<string, LLUUID> kp in Animations.AnimsLLUUID) 67 foreach (KeyValuePair<string, LLUUID> kp in Animations.AnimsLLUUID)
68 { 68 {
69 AnimsNames.Add(kp.Value, kp.Key); 69 AnimsNames.Add(kp.Value, kp.Key);
70 } 70 }
71 } 71 }
72 } 72 }
73 } 73 }
74} 74}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
index dbb5d3f..c2599a1 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs
@@ -1,85 +1,85 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using libsecondlife; 28using libsecondlife;
29using libsecondlife.Packets; 29using libsecondlife.Packets;
30using OpenSim.Framework.Interfaces; 30using OpenSim.Framework.Interfaces;
31 31
32namespace OpenSim.Region.Environment.Scenes 32namespace OpenSim.Region.Environment.Scenes
33{ 33{
34 partial class ScenePresence 34 partial class ScenePresence
35 { 35 {
36 public class Avatar : IScenePresenceBody 36 public class Avatar : IScenePresenceBody
37 { 37 {
38 public Avatar() 38 public Avatar()
39 { 39 {
40 40
41 } 41 }
42 42
43 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 43 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
44 { 44 {
45 } 45 }
46 46
47 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) 47 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
48 { 48 {
49 } 49 }
50 50
51 public void SendOurAppearance(IClientAPI OurClient) 51 public void SendOurAppearance(IClientAPI OurClient)
52 { 52 {
53 } 53 }
54 54
55 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) 55 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
56 { 56 {
57 } 57 }
58 } 58 }
59 59
60 public class ChildAgent : IScenePresenceBody //is a ghost 60 public class ChildAgent : IScenePresenceBody //is a ghost
61 { 61 {
62 public ChildAgent() 62 public ChildAgent()
63 { 63 {
64 64
65 } 65 }
66 66
67 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 67 public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
68 { 68 {
69 } 69 }
70 70
71 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) 71 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
72 { 72 {
73 } 73 }
74 74
75 public void SendOurAppearance(IClientAPI OurClient) 75 public void SendOurAppearance(IClientAPI OurClient)
76 { 76 {
77 } 77 }
78 78
79 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) 79 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
80 { 80 {
81 } 81 }
82 } 82 }
83 } 83 }
84 84
85} 85}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index b619b59..ae49d9f 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1,623 +1,623 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using Axiom.Math; 31using Axiom.Math;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Physics.Manager; 37using OpenSim.Physics.Manager;
38 38
39namespace OpenSim.Region.Environment.Scenes 39namespace OpenSim.Region.Environment.Scenes
40{ 40{
41 public partial class ScenePresence : Entity 41 public partial class ScenePresence : Entity
42 { 42 {
43 public static bool PhysicsEngineFlying = false; 43 public static bool PhysicsEngineFlying = false;
44 public static AvatarAnimations Animations; 44 public static AvatarAnimations Animations;
45 public static byte[] DefaultTexture; 45 public static byte[] DefaultTexture;
46 public string firstname; 46 public string firstname;
47 public string lastname; 47 public string lastname;
48 public IClientAPI ControllingClient; 48 public IClientAPI ControllingClient;
49 public LLUUID current_anim; 49 public LLUUID current_anim;
50 public int anim_seq; 50 public int anim_seq;
51 private bool updateflag = false; 51 private bool updateflag = false;
52 private byte movementflag = 0; 52 private byte movementflag = 0;
53 private List<NewForce> forcesList = new List<NewForce>(); 53 private List<NewForce> forcesList = new List<NewForce>();
54 private short _updateCount = 0; 54 private short _updateCount = 0;
55 private Quaternion bodyRot; 55 private Quaternion bodyRot;
56 private LLObject.TextureEntry avatarAppearanceTexture = null; 56 private LLObject.TextureEntry avatarAppearanceTexture = null;
57 private byte[] visualParams; 57 private byte[] visualParams;
58 private AvatarWearable[] Wearables; 58 private AvatarWearable[] Wearables;
59 private ulong m_regionHandle; 59 private ulong m_regionHandle;
60 60
61 public bool childAgent = false; 61 public bool childAgent = false;
62 public bool IsRestrictedToRegion = false; 62 public bool IsRestrictedToRegion = false;
63 63
64 private bool newForce = false; 64 private bool newForce = false;
65 private bool newAvatar = false; 65 private bool newAvatar = false;
66 private IScenePresenceBody m_body; 66 private IScenePresenceBody m_body;
67 67
68 protected RegionInfo m_regionInfo; 68 protected RegionInfo m_regionInfo;
69 69
70 private Vector3[] Dir_Vectors = new Vector3[6]; 70 private Vector3[] Dir_Vectors = new Vector3[6];
71 private enum Dir_ControlFlags 71 private enum Dir_ControlFlags
72 { 72 {
73 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, 73 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
74 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG, 74 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG,
75 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS, 75 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS,
76 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG, 76 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG,
77 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, 77 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
78 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG 78 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
79 } 79 }
80 /// <summary> 80 /// <summary>
81 /// Position at which a significant movement was made 81 /// Position at which a significant movement was made
82 /// </summary> 82 /// </summary>
83 private LLVector3 posLastSignificantMove = new LLVector3(); 83 private LLVector3 posLastSignificantMove = new LLVector3();
84 84
85 public delegate void SignificantClientMovement(IClientAPI remote_client); 85 public delegate void SignificantClientMovement(IClientAPI remote_client);
86 public event SignificantClientMovement OnSignificantClientMovement; 86 public event SignificantClientMovement OnSignificantClientMovement;
87 87
88 #region Properties 88 #region Properties
89 /// <summary> 89 /// <summary>
90 /// 90 ///
91 /// </summary> 91 /// </summary>
92 public PhysicsActor PhysActor 92 public PhysicsActor PhysActor
93 { 93 {
94 set 94 set
95 { 95 {
96 this._physActor = value; 96 this._physActor = value;
97 } 97 }
98 get 98 get
99 { 99 {
100 return _physActor; 100 return _physActor;
101 } 101 }
102 } 102 }
103 103
104 public ulong RegionHandle 104 public ulong RegionHandle
105 { 105 {
106 get { return m_regionHandle; } 106 get { return m_regionHandle; }
107 } 107 }
108 108
109 #endregion 109 #endregion
110 110
111 #region Constructor(s) 111 #region Constructor(s)
112 /// <summary> 112 /// <summary>
113 /// 113 ///
114 /// </summary> 114 /// </summary>
115 /// <param name="theClient"></param> 115 /// <param name="theClient"></param>
116 /// <param name="world"></param> 116 /// <param name="world"></param>
117 /// <param name="clientThreads"></param> 117 /// <param name="clientThreads"></param>
118 /// <param name="regionDat"></param> 118 /// <param name="regionDat"></param>
119 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) 119 public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo)
120 { 120 {
121 121
122 m_world = world; 122 m_world = world;
123 this.uuid = theClient.AgentId; 123 this.uuid = theClient.AgentId;
124 124
125 m_regionInfo = reginfo; 125 m_regionInfo = reginfo;
126 m_regionHandle = reginfo.RegionHandle; 126 m_regionHandle = reginfo.RegionHandle;
127 MainLog.Instance.Verbose("Avatar.cs "); 127 MainLog.Instance.Verbose("Avatar.cs ");
128 ControllingClient = theClient; 128 ControllingClient = theClient;
129 this.firstname = ControllingClient.FirstName; 129 this.firstname = ControllingClient.FirstName;
130 this.lastname = ControllingClient.LastName; 130 this.lastname = ControllingClient.LastName;
131 m_localId = m_world.NextLocalId; 131 m_localId = m_world.NextLocalId;
132 Pos = ControllingClient.StartPos; 132 Pos = ControllingClient.StartPos;
133 visualParams = new byte[218]; 133 visualParams = new byte[218];
134 for (int i = 0; i < 218; i++) 134 for (int i = 0; i < 218; i++)
135 { 135 {
136 visualParams[i] = 100; 136 visualParams[i] = 100;
137 } 137 }
138 138
139 Wearables = AvatarWearable.DefaultWearables; 139 Wearables = AvatarWearable.DefaultWearables;
140 Animations = new ScenePresence.AvatarAnimations(); 140 Animations = new ScenePresence.AvatarAnimations();
141 Animations.LoadAnims(); 141 Animations.LoadAnims();
142 142
143 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 143 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
144 144
145 //register for events 145 //register for events
146 ControllingClient.OnRequestWearables += this.SendOurAppearance; 146 ControllingClient.OnRequestWearables += this.SendOurAppearance;
147 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); 147 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
148 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; 148 ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement;
149 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; 149 ControllingClient.OnCompleteMovementToRegion += this.SendInitialData;
150 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; 150 ControllingClient.OnAgentUpdate += this.HandleAgentUpdate;
151 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); 151 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
152 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 152 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
153 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 153 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
154 154
155 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD 155 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
156 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK 156 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
157 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT 157 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
158 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT 158 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
159 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP 159 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
160 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN 160 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
161 161
162 } 162 }
163 #endregion 163 #endregion
164 164
165 #region Status Methods 165 #region Status Methods
166 /// <summary> 166 /// <summary>
167 /// Not Used, most likely can be deleted 167 /// Not Used, most likely can be deleted
168 /// </summary> 168 /// </summary>
169 /// <param name="status"></param> 169 /// <param name="status"></param>
170 public void ChildStatusChange(bool status) 170 public void ChildStatusChange(bool status)
171 { 171 {
172 this.childAgent = status; 172 this.childAgent = status;
173 173
174 if (this.childAgent == true) 174 if (this.childAgent == true)
175 { 175 {
176 this.Velocity = new LLVector3(0, 0, 0); 176 this.Velocity = new LLVector3(0, 0, 0);
177 this.Pos = new LLVector3(128, 128, 70); 177 this.Pos = new LLVector3(128, 128, 70);
178 178
179 } 179 }
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// 183 ///
184 /// </summary> 184 /// </summary>
185 /// <param name="pos"></param> 185 /// <param name="pos"></param>
186 public void MakeAvatar(LLVector3 pos) 186 public void MakeAvatar(LLVector3 pos)
187 { 187 {
188 //this.childAvatar = false; 188 //this.childAvatar = false;
189 this.Pos = pos; 189 this.Pos = pos;
190 this.newAvatar = true; 190 this.newAvatar = true;
191 this.childAgent = false; 191 this.childAgent = false;
192 } 192 }
193 193
194 protected void MakeChildAgent() 194 protected void MakeChildAgent()
195 { 195 {
196 this.Velocity = new LLVector3(0, 0, 0); 196 this.Velocity = new LLVector3(0, 0, 0);
197 this.Pos = new LLVector3(128, 128, 70); 197 this.Pos = new LLVector3(128, 128, 70);
198 this.childAgent = true; 198 this.childAgent = true;
199 } 199 }
200 200
201 /// <summary> 201 /// <summary>
202 /// 202 ///
203 /// </summary> 203 /// </summary>
204 /// <param name="pos"></param> 204 /// <param name="pos"></param>
205 public void Teleport(LLVector3 pos) 205 public void Teleport(LLVector3 pos)
206 { 206 {
207 this.Pos = pos; 207 this.Pos = pos;
208 this.SendTerseUpdateToALLClients(); 208 this.SendTerseUpdateToALLClients();
209 } 209 }
210 210
211 /// <summary> 211 /// <summary>
212 /// 212 ///
213 /// </summary> 213 /// </summary>
214 public void StopMovement() 214 public void StopMovement()
215 { 215 {
216 216
217 } 217 }
218 #endregion 218 #endregion
219 219
220 #region Event Handlers 220 #region Event Handlers
221 /// <summary> 221 /// <summary>
222 /// 222 ///
223 /// </summary> 223 /// </summary>
224 /// <param name="texture"></param> 224 /// <param name="texture"></param>
225 /// <param name="visualParam"></param> 225 /// <param name="visualParam"></param>
226 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) 226 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
227 { 227 {
228 228
229 } 229 }
230 230
231 /// <summary> 231 /// <summary>
232 /// Complete Avatar's movement into the region 232 /// Complete Avatar's movement into the region
233 /// </summary> 233 /// </summary>
234 public void CompleteMovement() 234 public void CompleteMovement()
235 { 235 {
236 LLVector3 look = this.Velocity; 236 LLVector3 look = this.Velocity;
237 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 237 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
238 { 238 {
239 look = new LLVector3(0.99f, 0.042f, 0); 239 look = new LLVector3(0.99f, 0.042f, 0);
240 } 240 }
241 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); 241 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look);
242 if (this.childAgent) 242 if (this.childAgent)
243 { 243 {
244 this.childAgent = false; 244 this.childAgent = false;
245 } 245 }
246 } 246 }
247 247
248 /// <summary> 248 /// <summary>
249 /// 249 ///
250 /// </summary> 250 /// </summary>
251 /// <param name="pack"></param> 251 /// <param name="pack"></param>
252 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 252 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
253 { 253 {
254 int i = 0; 254 int i = 0;
255 bool update_movementflag = false; 255 bool update_movementflag = false;
256 bool update_rotation = false; 256 bool update_rotation = false;
257 bool DCFlagKeyPressed = false; 257 bool DCFlagKeyPressed = false;
258 Vector3 agent_control_v3 = new Vector3(0, 0, 0); 258 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
259 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 259 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
260 260
261 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); 261 this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
262 262
263 if (q != this.bodyRot) 263 if (q != this.bodyRot)
264 { 264 {
265 this.bodyRot = q; 265 this.bodyRot = q;
266 update_rotation = true; 266 update_rotation = true;
267 } 267 }
268 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) 268 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags)))
269 { 269 {
270 if ((flags & (uint)DCF) != 0) 270 if ((flags & (uint)DCF) != 0)
271 { 271 {
272 DCFlagKeyPressed = true; 272 DCFlagKeyPressed = true;
273 agent_control_v3 += Dir_Vectors[i]; 273 agent_control_v3 += Dir_Vectors[i];
274 if ((movementflag & (uint)DCF) == 0) 274 if ((movementflag & (uint)DCF) == 0)
275 { 275 {
276 movementflag += (byte)(uint)DCF; 276 movementflag += (byte)(uint)DCF;
277 update_movementflag = true; 277 update_movementflag = true;
278 } 278 }
279 } 279 }
280 else 280 else
281 { 281 {
282 if ((movementflag & (uint)DCF) != 0) 282 if ((movementflag & (uint)DCF) != 0)
283 { 283 {
284 movementflag -= (byte)(uint)DCF; 284 movementflag -= (byte)(uint)DCF;
285 update_movementflag = true; 285 update_movementflag = true;
286 286
287 } 287 }
288 } 288 }
289 i++; 289 i++;
290 } 290 }
291 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) 291 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
292 { 292 {
293 this.AddNewMovement(agent_control_v3, q); 293 this.AddNewMovement(agent_control_v3, q);
294 } 294 }
295 UpdateMovementAnimations(update_movementflag); 295 UpdateMovementAnimations(update_movementflag);
296 } 296 }
297 297
298 protected void UpdateMovementAnimations(bool update_movementflag) 298 protected void UpdateMovementAnimations(bool update_movementflag)
299 { 299 {
300 if (update_movementflag) 300 if (update_movementflag)
301 { 301 {
302 if (movementflag != 0) 302 if (movementflag != 0)
303 { 303 {
304 if (this._physActor.Flying) 304 if (this._physActor.Flying)
305 { 305 {
306 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); 306 this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1);
307 } 307 }
308 else 308 else
309 { 309 {
310 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); 310 this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1);
311 } 311 }
312 } 312 }
313 else 313 else
314 { 314 {
315 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); 315 this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1);
316 } 316 }
317 } 317 }
318 318
319 } 319 }
320 320
321 321
322 protected void AddNewMovement(Vector3 vec, Quaternion rotation) 322 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
323 { 323 {
324 NewForce newVelocity = new NewForce(); 324 NewForce newVelocity = new NewForce();
325 Vector3 direc = rotation * vec; 325 Vector3 direc = rotation * vec;
326 direc.Normalize(); 326 direc.Normalize();
327 327
328 direc = direc * ((0.03f) * 128f); 328 direc = direc * ((0.03f) * 128f);
329 if (this._physActor.Flying) 329 if (this._physActor.Flying)
330 direc *= 4; 330 direc *= 4;
331 331
332 newVelocity.X = direc.x; 332 newVelocity.X = direc.x;
333 newVelocity.Y = direc.y; 333 newVelocity.Y = direc.y;
334 newVelocity.Z = direc.z; 334 newVelocity.Z = direc.z;
335 this.forcesList.Add(newVelocity); 335 this.forcesList.Add(newVelocity);
336 } 336 }
337 337
338 #endregion 338 #endregion
339 339
340 #region Overridden Methods 340 #region Overridden Methods
341 /// <summary> 341 /// <summary>
342 /// 342 ///
343 /// </summary> 343 /// </summary>
344 public override void LandRenegerated() 344 public override void LandRenegerated()
345 { 345 {
346 346
347 } 347 }
348 348
349 /// <summary> 349 /// <summary>
350 /// 350 ///
351 /// </summary> 351 /// </summary>
352 public override void update() 352 public override void update()
353 { 353 {
354 if (this.childAgent == false) 354 if (this.childAgent == false)
355 { 355 {
356 if (this.newForce) 356 if (this.newForce)
357 { 357 {
358 this.SendTerseUpdateToALLClients(); 358 this.SendTerseUpdateToALLClients();
359 _updateCount = 0; 359 _updateCount = 0;
360 } 360 }
361 else if (movementflag != 0) 361 else if (movementflag != 0)
362 { 362 {
363 _updateCount++; 363 _updateCount++;
364 if (_updateCount > 3) 364 if (_updateCount > 3)
365 { 365 {
366 this.SendTerseUpdateToALLClients(); 366 this.SendTerseUpdateToALLClients();
367 _updateCount = 0; 367 _updateCount = 0;
368 } 368 }
369 } 369 }
370 370
371 this.CheckForSignificantMovement(); 371 this.CheckForSignificantMovement();
372 this.CheckForBorderCrossing(); 372 this.CheckForBorderCrossing();
373 373
374 } 374 }
375 } 375 }
376 #endregion 376 #endregion
377 377
378 #region Update Client(s) 378 #region Update Client(s)
379 /// <summary> 379 /// <summary>
380 /// 380 ///
381 /// </summary> 381 /// </summary>
382 /// <param name="RemoteClient"></param> 382 /// <param name="RemoteClient"></param>
383 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 383 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
384 { 384 {
385 LLVector3 pos = this.Pos; 385 LLVector3 pos = this.Pos;
386 LLVector3 vel = this.Velocity; 386 LLVector3 vel = this.Velocity;
387 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); 387 RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z));
388 } 388 }
389 389
390 /// <summary> 390 /// <summary>
391 /// 391 ///
392 /// </summary> 392 /// </summary>
393 public void SendTerseUpdateToALLClients() 393 public void SendTerseUpdateToALLClients()
394 { 394 {
395 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 395 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
396 for (int i = 0; i < avatars.Count; i++) 396 for (int i = 0; i < avatars.Count; i++)
397 { 397 {
398 this.SendTerseUpdateToClient(avatars[i].ControllingClient); 398 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
399 } 399 }
400 } 400 }
401 401
402 /// <summary> 402 /// <summary>
403 /// 403 ///
404 /// </summary> 404 /// </summary>
405 /// <param name="remoteAvatar"></param> 405 /// <param name="remoteAvatar"></param>
406 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 406 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
407 { 407 {
408 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); 408 remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
409 } 409 }
410 410
411 public void SendFullUpdateToALLClients() 411 public void SendFullUpdateToALLClients()
412 { 412 {
413 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 413 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
414 foreach (ScenePresence avatar in this.m_world.RequestAvatarList()) 414 foreach (ScenePresence avatar in this.m_world.RequestAvatarList())
415 { 415 {
416 this.SendFullUpdateToOtherClient(avatar); 416 this.SendFullUpdateToOtherClient(avatar);
417 avatar.SendFullUpdateToOtherClient(this); 417 avatar.SendFullUpdateToOtherClient(this);
418 } 418 }
419 } 419 }
420 420
421 /// <summary> 421 /// <summary>
422 /// 422 ///
423 /// </summary> 423 /// </summary>
424 public void SendInitialData() 424 public void SendInitialData()
425 { 425 {
426 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); 426 this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
427 if (this.newAvatar) 427 if (this.newAvatar)
428 { 428 {
429 this.m_world.InformClientOfNeighbours(this.ControllingClient); 429 this.m_world.InformClientOfNeighbours(this.ControllingClient);
430 this.newAvatar = false; 430 this.newAvatar = false;
431 } 431 }
432 } 432 }
433 433
434 /// <summary> 434 /// <summary>
435 /// 435 ///
436 /// </summary> 436 /// </summary>
437 /// <param name="OurClient"></param> 437 /// <param name="OurClient"></param>
438 public void SendOurAppearance(IClientAPI OurClient) 438 public void SendOurAppearance(IClientAPI OurClient)
439 { 439 {
440 this.ControllingClient.SendWearables(this.Wearables); 440 this.ControllingClient.SendWearables(this.Wearables);
441 this.SendFullUpdateToALLClients(); 441 this.SendFullUpdateToALLClients();
442 this.m_world.SendAllSceneObjectsToClient(this.ControllingClient); 442 this.m_world.SendAllSceneObjectsToClient(this.ControllingClient);
443 } 443 }
444 444
445 /// <summary> 445 /// <summary>
446 /// 446 ///
447 /// </summary> 447 /// </summary>
448 /// <param name="avatarInfo"></param> 448 /// <param name="avatarInfo"></param>
449 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) 449 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
450 { 450 {
451 451
452 } 452 }
453 453
454 /// <summary> 454 /// <summary>
455 /// 455 ///
456 /// </summary> 456 /// </summary>
457 /// <param name="animID"></param> 457 /// <param name="animID"></param>
458 /// <param name="seq"></param> 458 /// <param name="seq"></param>
459 public void SendAnimPack(LLUUID animID, int seq) 459 public void SendAnimPack(LLUUID animID, int seq)
460 { 460 {
461 this.current_anim = animID; 461 this.current_anim = animID;
462 this.anim_seq = seq; 462 this.anim_seq = seq;
463 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 463 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
464 for (int i = 0; i < avatars.Count; i++) 464 for (int i = 0; i < avatars.Count; i++)
465 { 465 {
466 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); 466 avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId);
467 } 467 }
468 } 468 }
469 469
470 /// <summary> 470 /// <summary>
471 /// 471 ///
472 /// </summary> 472 /// </summary>
473 public void SendAnimPack() 473 public void SendAnimPack()
474 { 474 {
475 this.SendAnimPack(this.current_anim, this.anim_seq); 475 this.SendAnimPack(this.current_anim, this.anim_seq);
476 } 476 }
477 #endregion 477 #endregion
478 478
479 #region Significant Movement Method 479 #region Significant Movement Method
480 480
481 protected void CheckForSignificantMovement() 481 protected void CheckForSignificantMovement()
482 { 482 {
483 if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0) 483 if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0)
484 { 484 {
485 this.posLastSignificantMove = this.Pos; 485 this.posLastSignificantMove = this.Pos;
486 if (OnSignificantClientMovement != null) 486 if (OnSignificantClientMovement != null)
487 { 487 {
488 OnSignificantClientMovement(this.ControllingClient); 488 OnSignificantClientMovement(this.ControllingClient);
489 } 489 }
490 } 490 }
491 } 491 }
492 #endregion 492 #endregion
493 #region Border Crossing Methods 493 #region Border Crossing Methods
494 /// <summary> 494 /// <summary>
495 /// 495 ///
496 /// </summary> 496 /// </summary>
497 protected void CheckForBorderCrossing() 497 protected void CheckForBorderCrossing()
498 { 498 {
499 LLVector3 pos2 = this.Pos; 499 LLVector3 pos2 = this.Pos;
500 LLVector3 vel = this.Velocity; 500 LLVector3 vel = this.Velocity;
501 501
502 float timeStep = 0.2f; 502 float timeStep = 0.2f;
503 pos2.X = pos2.X + (vel.X * timeStep); 503 pos2.X = pos2.X + (vel.X * timeStep);
504 pos2.Y = pos2.Y + (vel.Y * timeStep); 504 pos2.Y = pos2.Y + (vel.Y * timeStep);
505 pos2.Z = pos2.Z + (vel.Z * timeStep); 505 pos2.Z = pos2.Z + (vel.Z * timeStep);
506 506
507 if ((pos2.X < 0) || (pos2.X > 256)) 507 if ((pos2.X < 0) || (pos2.X > 256))
508 { 508 {
509 this.CrossToNewRegion(); 509 this.CrossToNewRegion();
510 } 510 }
511 511
512 if ((pos2.Y < 0) || (pos2.Y > 256)) 512 if ((pos2.Y < 0) || (pos2.Y > 256))
513 { 513 {
514 this.CrossToNewRegion(); 514 this.CrossToNewRegion();
515 } 515 }
516 } 516 }
517 517
518 /// <summary> 518 /// <summary>
519 /// 519 ///
520 /// </summary> 520 /// </summary>
521 protected void CrossToNewRegion() 521 protected void CrossToNewRegion()
522 { 522 {
523 LLVector3 pos = this.Pos; 523 LLVector3 pos = this.Pos;
524 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); 524 LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z);
525 uint neighbourx = this.m_regionInfo.RegionLocX; 525 uint neighbourx = this.m_regionInfo.RegionLocX;
526 uint neighboury = this.m_regionInfo.RegionLocY; 526 uint neighboury = this.m_regionInfo.RegionLocY;
527 527
528 if (pos.X < 2) 528 if (pos.X < 2)
529 { 529 {
530 neighbourx -= 1; 530 neighbourx -= 1;
531 newpos.X = 254; 531 newpos.X = 254;
532 } 532 }
533 if (pos.X > 253) 533 if (pos.X > 253)
534 { 534 {
535 neighbourx += 1; 535 neighbourx += 1;
536 newpos.X = 1; 536 newpos.X = 1;
537 } 537 }
538 if (pos.Y < 2) 538 if (pos.Y < 2)
539 { 539 {
540 neighboury -= 1; 540 neighboury -= 1;
541 newpos.Y = 254; 541 newpos.Y = 254;
542 } 542 }
543 if (pos.Y > 253) 543 if (pos.Y > 253)
544 { 544 {
545 neighboury += 1; 545 neighboury += 1;
546 newpos.Y = 1; 546 newpos.Y = 1;
547 } 547 }
548 548
549 LLVector3 vel = this.m_velocity; 549 LLVector3 vel = this.m_velocity;
550 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); 550 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
551 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); 551 RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle);
552 if (neighbourRegion != null) 552 if (neighbourRegion != null)
553 { 553 {
554 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); 554 bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos);
555 if (res) 555 if (res)
556 { 556 {
557 this.MakeChildAgent(); 557 this.MakeChildAgent();
558 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint); 558 this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint);
559 } 559 }
560 } 560 }
561 } 561 }
562 #endregion 562 #endregion
563 563
564 /// <summary> 564 /// <summary>
565 /// 565 ///
566 /// </summary> 566 /// </summary>
567 public static void LoadAnims() 567 public static void LoadAnims()
568 { 568 {
569 569
570 } 570 }
571 571
572 /// <summary> 572 /// <summary>
573 /// 573 ///
574 /// </summary> 574 /// </summary>
575 public override void updateMovement() 575 public override void updateMovement()
576 { 576 {
577 newForce = false; 577 newForce = false;
578 lock (this.forcesList) 578 lock (this.forcesList)
579 { 579 {
580 if (this.forcesList.Count > 0) 580 if (this.forcesList.Count > 0)
581 { 581 {
582 for (int i = 0; i < this.forcesList.Count; i++) 582 for (int i = 0; i < this.forcesList.Count; i++)
583 { 583 {
584 NewForce force = this.forcesList[i]; 584 NewForce force = this.forcesList[i];
585 585
586 this.updateflag = true; 586 this.updateflag = true;
587 this.Velocity = new LLVector3(force.X, force.Y, force.Z); 587 this.Velocity = new LLVector3(force.X, force.Y, force.Z);
588 this.newForce = true; 588 this.newForce = true;
589 } 589 }
590 for (int i = 0; i < this.forcesList.Count; i++) 590 for (int i = 0; i < this.forcesList.Count; i++)
591 { 591 {
592 this.forcesList.RemoveAt(0); 592 this.forcesList.RemoveAt(0);
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 597
598 public static void LoadTextureFile(string name) 598 public static void LoadTextureFile(string name)
599 { 599 {
600 FileInfo fInfo = new FileInfo(name); 600 FileInfo fInfo = new FileInfo(name);
601 long numBytes = fInfo.Length; 601 long numBytes = fInfo.Length;
602 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 602 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
603 BinaryReader br = new BinaryReader(fStream); 603 BinaryReader br = new BinaryReader(fStream);
604 byte[] data1 = br.ReadBytes((int)numBytes); 604 byte[] data1 = br.ReadBytes((int)numBytes);
605 br.Close(); 605 br.Close();
606 fStream.Close(); 606 fStream.Close();
607 DefaultTexture = data1; 607 DefaultTexture = data1;
608 } 608 }
609 609
610 public class NewForce 610 public class NewForce
611 { 611 {
612 public float X; 612 public float X;
613 public float Y; 613 public float Y;
614 public float Z; 614 public float Z;
615 615
616 public NewForce() 616 public NewForce()
617 { 617 {
618 618
619 } 619 }
620 } 620 }
621 } 621 }
622 622
623} 623}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
index 1fc576e..b0ccd22 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
@@ -1,102 +1,102 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.CodeDom.Compiler; 29using System.CodeDom.Compiler;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using Microsoft.CSharp; 31using Microsoft.CSharp;
32using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
33 33
34namespace OpenSim.Region.Scripting 34namespace OpenSim.Region.Scripting
35{ 35{
36 public class CSharpScriptEngine : IScriptCompiler 36 public class CSharpScriptEngine : IScriptCompiler
37 { 37 {
38 public string FileExt() 38 public string FileExt()
39 { 39 {
40 return ".cs"; 40 return ".cs";
41 } 41 }
42 42
43 private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) 43 private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
44 { 44 {
45 CompilerParameters compilerParams = new CompilerParameters(); 45 CompilerParameters compilerParams = new CompilerParameters();
46 CompilerResults compilerResults; 46 CompilerResults compilerResults;
47 compilerParams.GenerateExecutable = false; 47 compilerParams.GenerateExecutable = false;
48 compilerParams.GenerateInMemory = true; 48 compilerParams.GenerateInMemory = true;
49 compilerParams.IncludeDebugInformation = false; 49 compilerParams.IncludeDebugInformation = false;
50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); 50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); 51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); 52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); 53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
54 compilerParams.ReferencedAssemblies.Add("System.dll"); 54 compilerParams.ReferencedAssemblies.Add("System.dll");
55 55
56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); 56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
57 57
58 if (compilerResults.Errors.Count > 0) 58 if (compilerResults.Errors.Count > 0)
59 { 59 {
60 MainLog.Instance.Error("Compile errors"); 60 MainLog.Instance.Error("Compile errors");
61 foreach (CompilerError error in compilerResults.Errors) 61 foreach (CompilerError error in compilerResults.Errors)
62 { 62 {
63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); 63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
64 } 64 }
65 } 65 }
66 else 66 else
67 { 67 {
68 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>(); 68 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
69 69
70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) 70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
71 { 71 {
72 Type testInterface = pluginType.GetInterface("IScript", true); 72 Type testInterface = pluginType.GetInterface("IScript", true);
73 73
74 if (testInterface != null) 74 if (testInterface != null)
75 { 75 {
76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); 76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
77 77
78 string scriptName = "C#/" + script.getName(); 78 string scriptName = "C#/" + script.getName();
79 Console.WriteLine("Script: " + scriptName + " loaded."); 79 Console.WriteLine("Script: " + scriptName + " loaded.");
80 80
81 if (!scripts.ContainsKey(scriptName)) 81 if (!scripts.ContainsKey(scriptName))
82 { 82 {
83 scripts.Add(scriptName, script); 83 scripts.Add(scriptName, script);
84 } 84 }
85 else 85 else
86 { 86 {
87 scripts[scriptName] = script; 87 scripts[scriptName] = script;
88 } 88 }
89 } 89 }
90 } 90 }
91 return scripts; 91 return scripts;
92 } 92 }
93 return null; 93 return null;
94 } 94 }
95 95
96 public Dictionary<string,IScript> compile(string filename) 96 public Dictionary<string,IScript> compile(string filename)
97 { 97 {
98 CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); 98 CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
99 return LoadDotNetScript(csharpProvider, filename); 99 return LoadDotNetScript(csharpProvider, filename);
100 } 100 }
101 } 101 }
102} 102}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs
index d9f1f0a..79d88b1 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs
@@ -1,70 +1,70 @@
1using OpenSim.Framework.Console; 1using OpenSim.Framework.Console;
2using OpenSim.Framework; 2using OpenSim.Framework;
3using OpenSim.Region.Environment; 3using OpenSim.Region.Environment;
4using OpenSim.Region.Environment.Scenes; 4using OpenSim.Region.Environment.Scenes;
5 5
6using System.Collections.Generic; 6using System.Collections.Generic;
7using libsecondlife; 7using libsecondlife;
8 8
9namespace OpenSim.Region.Scripting.Examples 9namespace OpenSim.Region.Scripting.Examples
10{ 10{
11 public class LSLExportScript : IScript 11 public class LSLExportScript : IScript
12 { 12 {
13 ScriptInfo script; 13 ScriptInfo script;
14 14
15 public string getName() 15 public string getName()
16 { 16 {
17 return "LSL Export Script 0.1"; 17 return "LSL Export Script 0.1";
18 } 18 }
19 19
20 public void Initialise(ScriptInfo scriptInfo) 20 public void Initialise(ScriptInfo scriptInfo)
21 { 21 {
22 script = scriptInfo; 22 script = scriptInfo;
23 23
24 script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); 24 script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg);
25 } 25 }
26 26
27 void ProcessConsoleMsg(string[] args) 27 void ProcessConsoleMsg(string[] args)
28 { 28 {
29 if (args[0].ToLower() == "lslexport") 29 if (args[0].ToLower() == "lslexport")
30 { 30 {
31 string sequence = ""; 31 string sequence = "";
32 32
33 foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects) 33 foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects)
34 { 34 {
35 SceneObject root = obj.Value; 35 SceneObject root = obj.Value;
36 36
37 sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; 37 sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n";
38 38
39 string rootPrim = processPrimitiveToString(root.rootPrimitive); 39 string rootPrim = processPrimitiveToString(root.rootPrimitive);
40 40
41 sequence += "ROOT:" + rootPrim; 41 sequence += "ROOT:" + rootPrim;
42 42
43 foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children) 43 foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children)
44 { 44 {
45 string child = processPrimitiveToString(prim.Value); 45 string child = processPrimitiveToString(prim.Value);
46 sequence += "CHILD:" + child; 46 sequence += "CHILD:" + child;
47 } 47 }
48 } 48 }
49 49
50 System.Console.WriteLine(sequence); 50 System.Console.WriteLine(sequence);
51 } 51 }
52 } 52 }
53 53
54 string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim) 54 string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim)
55 { 55 {
56 string desc = prim.Description; 56 string desc = prim.Description;
57 string name = prim.Name; 57 string name = prim.Name;
58 LLVector3 pos = prim.Pos; 58 LLVector3 pos = prim.Pos;
59 LLVector3 rot = new LLVector3(); 59 LLVector3 rot = new LLVector3();
60 LLVector3 scale = prim.Scale; 60 LLVector3 scale = prim.Scale;
61 LLVector3 rootPos = prim.WorldPos; 61 LLVector3 rootPos = prim.WorldPos;
62 62
63 string setPrimParams = ""; 63 string setPrimParams = "";
64 64
65 setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; 65 setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n";
66 66
67 return setPrimParams; 67 return setPrimParams;
68 } 68 }
69 } 69 }
70} \ No newline at end of file 70} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
index 0833e7a..af4f8b4 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
@@ -1,102 +1,102 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.CodeDom.Compiler; 29using System.CodeDom.Compiler;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using Microsoft.JScript; 31using Microsoft.JScript;
32using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
33 33
34namespace OpenSim.Region.Scripting 34namespace OpenSim.Region.Scripting
35{ 35{
36 public class JScriptEngine : IScriptCompiler 36 public class JScriptEngine : IScriptCompiler
37 { 37 {
38 public string FileExt() 38 public string FileExt()
39 { 39 {
40 return ".js"; 40 return ".js";
41 } 41 }
42 42
43 private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) 43 private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
44 { 44 {
45 CompilerParameters compilerParams = new CompilerParameters(); 45 CompilerParameters compilerParams = new CompilerParameters();
46 CompilerResults compilerResults; 46 CompilerResults compilerResults;
47 compilerParams.GenerateExecutable = false; 47 compilerParams.GenerateExecutable = false;
48 compilerParams.GenerateInMemory = true; 48 compilerParams.GenerateInMemory = true;
49 compilerParams.IncludeDebugInformation = false; 49 compilerParams.IncludeDebugInformation = false;
50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); 50 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); 51 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); 52 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); 53 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
54 compilerParams.ReferencedAssemblies.Add("System.dll"); 54 compilerParams.ReferencedAssemblies.Add("System.dll");
55 55
56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); 56 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
57 57
58 if (compilerResults.Errors.Count > 0) 58 if (compilerResults.Errors.Count > 0)
59 { 59 {
60 MainLog.Instance.Error("Compile errors"); 60 MainLog.Instance.Error("Compile errors");
61 foreach (CompilerError error in compilerResults.Errors) 61 foreach (CompilerError error in compilerResults.Errors)
62 { 62 {
63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); 63 MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
64 } 64 }
65 } 65 }
66 else 66 else
67 { 67 {
68 Dictionary<string, IScript> scripts = new Dictionary<string, IScript>(); 68 Dictionary<string, IScript> scripts = new Dictionary<string, IScript>();
69 69
70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) 70 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
71 { 71 {
72 Type testInterface = pluginType.GetInterface("IScript", true); 72 Type testInterface = pluginType.GetInterface("IScript", true);
73 73
74 if (testInterface != null) 74 if (testInterface != null)
75 { 75 {
76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); 76 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
77 77
78 string scriptName = "JS.NET/" + script.getName(); 78 string scriptName = "JS.NET/" + script.getName();
79 Console.WriteLine("Script: " + scriptName + " loaded."); 79 Console.WriteLine("Script: " + scriptName + " loaded.");
80 80
81 if (!scripts.ContainsKey(scriptName)) 81 if (!scripts.ContainsKey(scriptName))
82 { 82 {
83 scripts.Add(scriptName, script); 83 scripts.Add(scriptName, script);
84 } 84 }
85 else 85 else
86 { 86 {
87 scripts[scriptName] = script; 87 scripts[scriptName] = script;
88 } 88 }
89 } 89 }
90 } 90 }
91 return scripts; 91 return scripts;
92 } 92 }
93 return null; 93 return null;
94 } 94 }
95 95
96 public Dictionary<string, IScript> compile(string filename) 96 public Dictionary<string, IScript> compile(string filename)
97 { 97 {
98 JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); 98 JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
99 return LoadDotNetScript(jscriptProvider, filename); 99 return LoadDotNetScript(jscriptProvider, filename);
100 } 100 }
101 } 101 }
102} 102}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs
index 0b1cf41..ca729b4 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs
@@ -1,45 +1,45 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32 32
33namespace OpenSim.Region.Scripting.EmbeddedJVM 33namespace OpenSim.Region.Scripting.EmbeddedJVM
34{ 34{
35 public class ClassInstance : Object 35 public class ClassInstance : Object
36 { 36 {
37 public int size; 37 public int size;
38 public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>(); 38 public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
39 39
40 public ClassInstance() 40 public ClassInstance()
41 { 41 {
42 42
43 } 43 }
44 } 44 }
45} 45}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs
index f821f52..f151b7e 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs
@@ -1,503 +1,503 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using OpenSim.Region.Scripting.EmbeddedJVM.Types; 32using OpenSim.Region.Scripting.EmbeddedJVM.Types;
33 33
34namespace OpenSim.Region.Scripting.EmbeddedJVM 34namespace OpenSim.Region.Scripting.EmbeddedJVM
35{ 35{
36 public class ClassRecord 36 public class ClassRecord
37 { 37 {
38 private ushort _majorVersion; 38 private ushort _majorVersion;
39 private ushort _minorVersion; 39 private ushort _minorVersion;
40 private ushort _constantPoolCount; 40 private ushort _constantPoolCount;
41 private ushort _accessFlags; 41 private ushort _accessFlags;
42 private ushort _thisClass; 42 private ushort _thisClass;
43 private ushort _supperClass; 43 private ushort _supperClass;
44 private ushort _interfaceCount; 44 private ushort _interfaceCount;
45 private ushort _fieldCount; 45 private ushort _fieldCount;
46 private ushort _methodCount; 46 private ushort _methodCount;
47 //private ushort _attributeCount; 47 //private ushort _attributeCount;
48 //private string _name; 48 //private string _name;
49 public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>(); 49 public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>();
50 public PoolClass mClass; 50 public PoolClass mClass;
51 51
52 public List<PoolItem> _constantsPool = new List<PoolItem>(); 52 public List<PoolItem> _constantsPool = new List<PoolItem>();
53 private List<MethodInfo> _methodsList = new List<MethodInfo>(); 53 private List<MethodInfo> _methodsList = new List<MethodInfo>();
54 private List<FieldInfo> _fieldList = new List<FieldInfo>(); 54 private List<FieldInfo> _fieldList = new List<FieldInfo>();
55 55
56 public ClassRecord() 56 public ClassRecord()
57 { 57 {
58 58
59 } 59 }
60 60
61 public ClassInstance CreateNewInstance() 61 public ClassInstance CreateNewInstance()
62 { 62 {
63 return new ClassInstance(); 63 return new ClassInstance();
64 } 64 }
65 65
66 public void LoadClassFromFile(string fileName) 66 public void LoadClassFromFile(string fileName)
67 { 67 {
68 Console.WriteLine("loading script " + fileName); 68 Console.WriteLine("loading script " + fileName);
69 FileStream fs = File.OpenRead(fileName); 69 FileStream fs = File.OpenRead(fileName);
70 this.LoadClassFromBytes(ReadFully(fs)); 70 this.LoadClassFromBytes(ReadFully(fs));
71 fs.Close(); 71 fs.Close();
72 } 72 }
73 73
74 public void LoadClassFromBytes(byte[] data) 74 public void LoadClassFromBytes(byte[] data)
75 { 75 {
76 int i = 0; 76 int i = 0;
77 i += 4; 77 i += 4;
78 _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); 78 _minorVersion = (ushort)((data[i++] << 8) + data[i++] );
79 _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); 79 _majorVersion = (ushort)((data[i++] << 8) + data[i++] );
80 _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); 80 _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] );
81 // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); 81 // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
82 for (int count = 0; count < _constantPoolCount -1 ; count++) 82 for (int count = 0; count < _constantPoolCount -1 ; count++)
83 { 83 {
84 //read in the constant pool 84 //read in the constant pool
85 byte pooltype = data[i++]; 85 byte pooltype = data[i++];
86 //Console.WriteLine("#" +count +": new constant type = " +pooltype); 86 //Console.WriteLine("#" +count +": new constant type = " +pooltype);
87 //Console.WriteLine("start position is: " + i); 87 //Console.WriteLine("start position is: " + i);
88 switch (pooltype) 88 switch (pooltype)
89 { 89 {
90 case 1: //Utf8 90 case 1: //Utf8
91 ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); 91 ushort uLength = (ushort)((data[i++] << 8) + data[i++] );
92 92
93 // Console.WriteLine("new utf8 type, length is " + uLength); 93 // Console.WriteLine("new utf8 type, length is " + uLength);
94 PoolUtf8 utf8 = new PoolUtf8(); 94 PoolUtf8 utf8 = new PoolUtf8();
95 utf8.readValue(data, ref i, uLength); 95 utf8.readValue(data, ref i, uLength);
96 this._constantsPool.Add(utf8); 96 this._constantsPool.Add(utf8);
97 break; 97 break;
98 case 3: //Int 98 case 3: //Int
99 break; 99 break;
100 case 7: //Class 100 case 7: //Class
101 PoolClass pClass = new PoolClass(this); 101 PoolClass pClass = new PoolClass(this);
102 pClass.readValue(data, ref i); 102 pClass.readValue(data, ref i);
103 this._constantsPool.Add(pClass); 103 this._constantsPool.Add(pClass);
104 break; 104 break;
105 case 10: //Method 105 case 10: //Method
106 PoolMethodRef pMeth = new PoolMethodRef(this); 106 PoolMethodRef pMeth = new PoolMethodRef(this);
107 pMeth.readValue(data, ref i); 107 pMeth.readValue(data, ref i);
108 this._constantsPool.Add(pMeth); 108 this._constantsPool.Add(pMeth);
109 break; 109 break;
110 case 12: //NamedType 110 case 12: //NamedType
111 PoolNamedType pNamed = new PoolNamedType(this); 111 PoolNamedType pNamed = new PoolNamedType(this);
112 pNamed.readValue(data, ref i); 112 pNamed.readValue(data, ref i);
113 this._constantsPool.Add(pNamed); 113 this._constantsPool.Add(pNamed);
114 break; 114 break;
115 } 115 }
116 } 116 }
117 117
118 _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); 118 _accessFlags = (ushort)((data[i++] << 8) + data[i++] );
119 _thisClass = (ushort)((data[i++] << 8) + data[i++] ); 119 _thisClass = (ushort)((data[i++] << 8) + data[i++] );
120 _supperClass = (ushort)((data[i++] << 8) + data[i++] ); 120 _supperClass = (ushort)((data[i++] << 8) + data[i++] );
121 121
122 if (this._constantsPool[this._thisClass - 1] is PoolClass) 122 if (this._constantsPool[this._thisClass - 1] is PoolClass)
123 { 123 {
124 this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); 124 this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]);
125 } 125 }
126 126
127 _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); 127 _interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
128 //should now read in the info for each interface 128 //should now read in the info for each interface
129 _fieldCount = (ushort)((data[i++] << 8) + data[i++]); 129 _fieldCount = (ushort)((data[i++] << 8) + data[i++]);
130 //should now read in the info for each field 130 //should now read in the info for each field
131 _methodCount = (ushort)((data[i++] << 8) + data[i++]); 131 _methodCount = (ushort)((data[i++] << 8) + data[i++]);
132 for (int count = 0; count < _methodCount; count++) 132 for (int count = 0; count < _methodCount; count++)
133 { 133 {
134 MethodInfo methInf = new MethodInfo(this); 134 MethodInfo methInf = new MethodInfo(this);
135 methInf.ReadData(data, ref i); 135 methInf.ReadData(data, ref i);
136 this._methodsList.Add(methInf); 136 this._methodsList.Add(methInf);
137 } 137 }
138 } 138 }
139 139
140 public void AddMethodsToMemory(MethodMemory memory) 140 public void AddMethodsToMemory(MethodMemory memory)
141 { 141 {
142 for (int count = 0; count < _methodCount; count++) 142 for (int count = 0; count < _methodCount; count++)
143 { 143 {
144 this._methodsList[count].AddMethodCode(memory); 144 this._methodsList[count].AddMethodCode(memory);
145 } 145 }
146 } 146 }
147 147
148 public bool StartMethod(Thread thread, string methodName) 148 public bool StartMethod(Thread thread, string methodName)
149 { 149 {
150 for (int count = 0; count < _methodCount; count++) 150 for (int count = 0; count < _methodCount; count++)
151 { 151 {
152 if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) 152 if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8)
153 { 153 {
154 if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) 154 if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName)
155 { 155 {
156 //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); 156 //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
157 thread.SetPC(this._methodsList[count].CodePointer); 157 thread.SetPC(this._methodsList[count].CodePointer);
158 return true; 158 return true;
159 } 159 }
160 } 160 }
161 } 161 }
162 return false; 162 return false;
163 } 163 }
164 164
165 public void PrintToConsole() 165 public void PrintToConsole()
166 { 166 {
167 Console.WriteLine("Class File:"); 167 Console.WriteLine("Class File:");
168 Console.WriteLine("Major version: " + _majorVersion); 168 Console.WriteLine("Major version: " + _majorVersion);
169 Console.WriteLine("Minor version: " + _minorVersion); 169 Console.WriteLine("Minor version: " + _minorVersion);
170 Console.WriteLine("Pool size: " + _constantPoolCount); 170 Console.WriteLine("Pool size: " + _constantPoolCount);
171 171
172 for (int i = 0; i < _constantsPool.Count; i++) 172 for (int i = 0; i < _constantsPool.Count; i++)
173 { 173 {
174 this._constantsPool[i].Print(); 174 this._constantsPool[i].Print();
175 } 175 }
176 176
177 Console.WriteLine("Access flags: " + _accessFlags); 177 Console.WriteLine("Access flags: " + _accessFlags);
178 Console.WriteLine("This class: " + _thisClass ); 178 Console.WriteLine("This class: " + _thisClass );
179 Console.WriteLine("Super class: " + _supperClass); 179 Console.WriteLine("Super class: " + _supperClass);
180 180
181 for (int count = 0; count < _methodCount; count++) 181 for (int count = 0; count < _methodCount; count++)
182 { 182 {
183 Console.WriteLine(); 183 Console.WriteLine();
184 this._methodsList[count].Print(); 184 this._methodsList[count].Print();
185 } 185 }
186 186
187 Console.WriteLine("class name is " + this.mClass.Name.Value); 187 Console.WriteLine("class name is " + this.mClass.Name.Value);
188 } 188 }
189 189
190 public static byte[] ReadFully(Stream stream) 190 public static byte[] ReadFully(Stream stream)
191 { 191 {
192 byte[] buffer = new byte[1024]; 192 byte[] buffer = new byte[1024];
193 using (MemoryStream ms = new MemoryStream()) 193 using (MemoryStream ms = new MemoryStream())
194 { 194 {
195 while (true) 195 while (true)
196 { 196 {
197 int read = stream.Read(buffer, 0, buffer.Length); 197 int read = stream.Read(buffer, 0, buffer.Length);
198 if (read <= 0) 198 if (read <= 0)
199 return ms.ToArray(); 199 return ms.ToArray();
200 ms.Write(buffer, 0, read); 200 ms.Write(buffer, 0, read);
201 } 201 }
202 } 202 }
203 } 203 }
204 204
205 #region nested classes 205 #region nested classes
206 public class PoolItem 206 public class PoolItem
207 { 207 {
208 public virtual void Print() 208 public virtual void Print()
209 { 209 {
210 210
211 } 211 }
212 } 212 }
213 213
214 public class PoolUtf8 : PoolItem 214 public class PoolUtf8 : PoolItem
215 { 215 {
216 public string Value = ""; 216 public string Value = "";
217 217
218 public void readValue(byte[] data,ref int pointer , int length) 218 public void readValue(byte[] data,ref int pointer , int length)
219 { 219 {
220 for (int i = 0; i < length; i++) 220 for (int i = 0; i < length; i++)
221 { 221 {
222 int a =(int) data[pointer++]; 222 int a =(int) data[pointer++];
223 if ((a & 0x80) == 0) 223 if ((a & 0x80) == 0)
224 { 224 {
225 Value = Value + (char)a; 225 Value = Value + (char)a;
226 } 226 }
227 else if ((a & 0x20) == 0) 227 else if ((a & 0x20) == 0)
228 { 228 {
229 int b = (int) data[pointer++]; 229 int b = (int) data[pointer++];
230 Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); 230 Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
231 } 231 }
232 else 232 else
233 { 233 {
234 int b = (int)data[pointer++]; 234 int b = (int)data[pointer++];
235 int c = (int)data[pointer++]; 235 int c = (int)data[pointer++];
236 Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); 236 Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 public override void Print() 241 public override void Print()
242 { 242 {
243 Console.WriteLine("Utf8 type: " + Value); 243 Console.WriteLine("Utf8 type: " + Value);
244 } 244 }
245 } 245 }
246 246
247 private class PoolInt : PoolItem 247 private class PoolInt : PoolItem
248 { 248 {
249 249
250 } 250 }
251 251
252 public class PoolClass : PoolItem 252 public class PoolClass : PoolItem
253 { 253 {
254 //public string name = ""; 254 //public string name = "";
255 public ushort namePointer = 0; 255 public ushort namePointer = 0;
256 private ClassRecord parent; 256 private ClassRecord parent;
257 public PoolUtf8 Name; 257 public PoolUtf8 Name;
258 258
259 public PoolClass(ClassRecord paren) 259 public PoolClass(ClassRecord paren)
260 { 260 {
261 parent = paren; 261 parent = paren;
262 } 262 }
263 263
264 public void readValue(byte[] data, ref int pointer) 264 public void readValue(byte[] data, ref int pointer)
265 { 265 {
266 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); 266 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
267 } 267 }
268 268
269 public override void Print() 269 public override void Print()
270 { 270 {
271 this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); 271 this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
272 Console.Write("Class type: " + namePointer); 272 Console.Write("Class type: " + namePointer);
273 Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); 273 Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
274 274
275 } 275 }
276 } 276 }
277 277
278 public class PoolMethodRef : PoolItem 278 public class PoolMethodRef : PoolItem
279 { 279 {
280 public ushort classPointer = 0; 280 public ushort classPointer = 0;
281 public ushort nameTypePointer = 0; 281 public ushort nameTypePointer = 0;
282 public PoolNamedType mNameType; 282 public PoolNamedType mNameType;
283 public PoolClass mClass; 283 public PoolClass mClass;
284 private ClassRecord parent; 284 private ClassRecord parent;
285 285
286 public PoolMethodRef(ClassRecord paren) 286 public PoolMethodRef(ClassRecord paren)
287 { 287 {
288 parent = paren; 288 parent = paren;
289 } 289 }
290 290
291 public void readValue(byte[] data, ref int pointer) 291 public void readValue(byte[] data, ref int pointer)
292 { 292 {
293 classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); 293 classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
294 nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); 294 nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
295 } 295 }
296 296
297 public override void Print() 297 public override void Print()
298 { 298 {
299 this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); 299 this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
300 this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); 300 this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
301 Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); 301 Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
302 } 302 }
303 } 303 }
304 304
305 public class PoolNamedType : PoolItem 305 public class PoolNamedType : PoolItem
306 { 306 {
307 public ushort namePointer = 0; 307 public ushort namePointer = 0;
308 public ushort typePointer = 0; 308 public ushort typePointer = 0;
309 private ClassRecord parent; 309 private ClassRecord parent;
310 public PoolUtf8 Name; 310 public PoolUtf8 Name;
311 public PoolUtf8 Type; 311 public PoolUtf8 Type;
312 312
313 public PoolNamedType(ClassRecord paren) 313 public PoolNamedType(ClassRecord paren)
314 { 314 {
315 parent = paren; 315 parent = paren;
316 } 316 }
317 317
318 public void readValue(byte[] data, ref int pointer) 318 public void readValue(byte[] data, ref int pointer)
319 { 319 {
320 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); 320 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
321 typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); 321 typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
322 } 322 }
323 323
324 public override void Print() 324 public override void Print()
325 { 325 {
326 Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); 326 Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]);
327 Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); 327 Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]);
328 Console.Write("Named type: " + namePointer + " , " + typePointer ); 328 Console.Write("Named type: " + namePointer + " , " + typePointer );
329 Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); 329 Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value);
330 } 330 }
331 } 331 }
332 332
333 //*********************** 333 //***********************
334 public class MethodInfo 334 public class MethodInfo
335 { 335 {
336 public ushort AccessFlags = 0; 336 public ushort AccessFlags = 0;
337 public ushort NameIndex = 0; 337 public ushort NameIndex = 0;
338 public string Name = ""; 338 public string Name = "";
339 public ushort DescriptorIndex = 0; 339 public ushort DescriptorIndex = 0;
340 public ushort AttributeCount = 0; 340 public ushort AttributeCount = 0;
341 public List<MethodAttribute> Attributes = new List<MethodAttribute>(); 341 public List<MethodAttribute> Attributes = new List<MethodAttribute>();
342 private ClassRecord parent; 342 private ClassRecord parent;
343 public int CodePointer = 0; 343 public int CodePointer = 0;
344 344
345 public MethodInfo(ClassRecord paren) 345 public MethodInfo(ClassRecord paren)
346 { 346 {
347 parent = paren; 347 parent = paren;
348 } 348 }
349 349
350 public void AddMethodCode(MethodMemory memory) 350 public void AddMethodCode(MethodMemory memory)
351 { 351 {
352 Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); 352 Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length);
353 memory.Methodcount++; 353 memory.Methodcount++;
354 this.CodePointer = memory.NextMethodPC; 354 this.CodePointer = memory.NextMethodPC;
355 memory.NextMethodPC += this.Attributes[0].Code.Length; 355 memory.NextMethodPC += this.Attributes[0].Code.Length;
356 } 356 }
357 357
358 public void ReadData(byte[] data, ref int pointer) 358 public void ReadData(byte[] data, ref int pointer)
359 { 359 {
360 AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); 360 AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]);
361 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); 361 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
362 DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); 362 DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
363 AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); 363 AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
364 for(int i =0; i< AttributeCount; i++) 364 for(int i =0; i< AttributeCount; i++)
365 { 365 {
366 MethodAttribute attri = new MethodAttribute(this.parent); 366 MethodAttribute attri = new MethodAttribute(this.parent);
367 attri.ReadData(data, ref pointer); 367 attri.ReadData(data, ref pointer);
368 this.Attributes.Add(attri); 368 this.Attributes.Add(attri);
369 } 369 }
370 } 370 }
371 371
372 public void Print() 372 public void Print()
373 { 373 {
374 Console.WriteLine("Method Info Struct: "); 374 Console.WriteLine("Method Info Struct: ");
375 Console.WriteLine("AccessFlags: " + AccessFlags); 375 Console.WriteLine("AccessFlags: " + AccessFlags);
376 Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); 376 Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
377 Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); 377 Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value);
378 Console.WriteLine("Attribute Count:" + AttributeCount); 378 Console.WriteLine("Attribute Count:" + AttributeCount);
379 for (int i = 0; i < AttributeCount; i++) 379 for (int i = 0; i < AttributeCount; i++)
380 { 380 {
381 this.Attributes[i].Print(); 381 this.Attributes[i].Print();
382 } 382 }
383 } 383 }
384 384
385 public class MethodAttribute 385 public class MethodAttribute
386 { 386 {
387 public ushort NameIndex = 0; 387 public ushort NameIndex = 0;
388 public string Name = ""; 388 public string Name = "";
389 public Int32 Length = 0; 389 public Int32 Length = 0;
390 //for now only support code attribute 390 //for now only support code attribute
391 public ushort MaxStack = 0; 391 public ushort MaxStack = 0;
392 public ushort MaxLocals = 0; 392 public ushort MaxLocals = 0;
393 public Int32 CodeLength = 0; 393 public Int32 CodeLength = 0;
394 public byte[] Code; 394 public byte[] Code;
395 public ushort ExceptionTableLength = 0; 395 public ushort ExceptionTableLength = 0;
396 public ushort SubAttributeCount = 0; 396 public ushort SubAttributeCount = 0;
397 public List<SubAttribute> SubAttributes = new List<SubAttribute>(); 397 public List<SubAttribute> SubAttributes = new List<SubAttribute>();
398 private ClassRecord parent; 398 private ClassRecord parent;
399 399
400 public MethodAttribute(ClassRecord paren) 400 public MethodAttribute(ClassRecord paren)
401 { 401 {
402 parent = paren; 402 parent = paren;
403 } 403 }
404 404
405 public void ReadData(byte[] data, ref int pointer) 405 public void ReadData(byte[] data, ref int pointer)
406 { 406 {
407 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); 407 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
408 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); 408 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
409 MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); 409 MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]);
410 MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); 410 MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]);
411 CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); 411 CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
412 Code = new byte[CodeLength]; 412 Code = new byte[CodeLength];
413 for (int i = 0; i < CodeLength; i++) 413 for (int i = 0; i < CodeLength; i++)
414 { 414 {
415 Code[i] = data[pointer++]; 415 Code[i] = data[pointer++];
416 } 416 }
417 ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); 417 ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]);
418 SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); 418 SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
419 for (int i = 0; i < SubAttributeCount; i++) 419 for (int i = 0; i < SubAttributeCount; i++)
420 { 420 {
421 SubAttribute subAttri = new SubAttribute(this.parent); 421 SubAttribute subAttri = new SubAttribute(this.parent);
422 subAttri.ReadData(data, ref pointer); 422 subAttri.ReadData(data, ref pointer);
423 this.SubAttributes.Add(subAttri); 423 this.SubAttributes.Add(subAttri);
424 } 424 }
425 } 425 }
426 426
427 public void Print() 427 public void Print()
428 { 428 {
429 Console.WriteLine("Method Attribute: "); 429 Console.WriteLine("Method Attribute: ");
430 Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); 430 Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
431 Console.WriteLine("Length: " + Length); 431 Console.WriteLine("Length: " + Length);
432 Console.WriteLine("MaxStack: " + MaxStack); 432 Console.WriteLine("MaxStack: " + MaxStack);
433 Console.WriteLine("MaxLocals: " + MaxLocals); 433 Console.WriteLine("MaxLocals: " + MaxLocals);
434 Console.WriteLine("CodeLength: " + CodeLength); 434 Console.WriteLine("CodeLength: " + CodeLength);
435 for (int i = 0; i < Code.Length; i++) 435 for (int i = 0; i < Code.Length; i++)
436 { 436 {
437 Console.WriteLine("OpCode #" + i + " is: " + Code[i]); 437 Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
438 } 438 }
439 Console.WriteLine("SubAttributes: " + SubAttributeCount); 439 Console.WriteLine("SubAttributes: " + SubAttributeCount);
440 for (int i = 0; i < SubAttributeCount; i++) 440 for (int i = 0; i < SubAttributeCount; i++)
441 { 441 {
442 this.SubAttributes[i].Print(); 442 this.SubAttributes[i].Print();
443 } 443 }
444 } 444 }
445 445
446 public class SubAttribute 446 public class SubAttribute
447 { 447 {
448 public ushort NameIndex = 0; 448 public ushort NameIndex = 0;
449 public string Name = ""; 449 public string Name = "";
450 public Int32 Length = 0; 450 public Int32 Length = 0;
451 public byte[] Data; 451 public byte[] Data;
452 private ClassRecord parent; 452 private ClassRecord parent;
453 453
454 public SubAttribute(ClassRecord paren) 454 public SubAttribute(ClassRecord paren)
455 { 455 {
456 parent = paren; 456 parent = paren;
457 } 457 }
458 458
459 public void ReadData(byte[] data, ref int pointer) 459 public void ReadData(byte[] data, ref int pointer)
460 { 460 {
461 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); 461 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
462 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); 462 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
463 Data = new byte[Length]; 463 Data = new byte[Length];
464 for (int i = 0; i < Length; i++) 464 for (int i = 0; i < Length; i++)
465 { 465 {
466 Data[i] = data[pointer++]; 466 Data[i] = data[pointer++];
467 } 467 }
468 } 468 }
469 469
470 public void Print() 470 public void Print()
471 { 471 {
472 Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); 472 Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
473 } 473 }
474 474
475 } 475 }
476 } 476 }
477 477
478 } 478 }
479 private class InterfaceInfo 479 private class InterfaceInfo
480 { 480 {
481 public void ReadData(byte[] data, ref int i) 481 public void ReadData(byte[] data, ref int i)
482 { 482 {
483 483
484 } 484 }
485 } 485 }
486 private class FieldInfo 486 private class FieldInfo
487 { 487 {
488 public void ReadData(byte[] data, ref int i) 488 public void ReadData(byte[] data, ref int i)
489 { 489 {
490 490
491 } 491 }
492 } 492 }
493 private class AttributeInfo 493 private class AttributeInfo
494 { 494 {
495 public void ReadData(byte[] data, ref int i) 495 public void ReadData(byte[] data, ref int i)
496 { 496 {
497 497
498 } 498 }
499 } 499 }
500 #endregion 500 #endregion
501 501
502 } 502 }
503} 503}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs
index 1a97b7d..c6423fc 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs
@@ -1,43 +1,43 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 public class Heap 34 public class Heap
35 { 35 {
36 public List<ClassInstance> ClassObjects = new List<ClassInstance>(); 36 public List<ClassInstance> ClassObjects = new List<ClassInstance>();
37 37
38 public Heap() 38 public Heap()
39 { 39 {
40 40
41 } 41 }
42 } 42 }
43} 43}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs
index ef6b805..56135d3 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs
@@ -1,427 +1,427 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; 32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33 33
34namespace OpenSim.Region.Scripting.EmbeddedJVM 34namespace OpenSim.Region.Scripting.EmbeddedJVM
35{ 35{
36 partial class Thread 36 partial class Thread
37 { 37 {
38 private partial class Interpreter 38 private partial class Interpreter
39 { 39 {
40 private bool IsLogicOpCode(byte opcode) 40 private bool IsLogicOpCode(byte opcode)
41 { 41 {
42 bool result = false; 42 bool result = false;
43 switch (opcode) 43 switch (opcode)
44 { 44 {
45 case 2: 45 case 2:
46 Int m_int= new Int(); 46 Int m_int= new Int();
47 m_int.mValue = -1; 47 m_int.mValue = -1;
48 this._mThread.currentFrame.OpStack.Push(m_int); 48 this._mThread.currentFrame.OpStack.Push(m_int);
49 result = true; 49 result = true;
50 break; 50 break;
51 case 3: 51 case 3:
52 m_int= new Int(); 52 m_int= new Int();
53 m_int.mValue = 0; 53 m_int.mValue = 0;
54 this._mThread.currentFrame.OpStack.Push(m_int); 54 this._mThread.currentFrame.OpStack.Push(m_int);
55 result = true; 55 result = true;
56 break; 56 break;
57 case 4: 57 case 4:
58 m_int = new Int(); 58 m_int = new Int();
59 m_int.mValue = 1; 59 m_int.mValue = 1;
60 this._mThread.currentFrame.OpStack.Push(m_int); 60 this._mThread.currentFrame.OpStack.Push(m_int);
61 result = true; 61 result = true;
62 break; 62 break;
63 case 5: 63 case 5:
64 m_int = new Int(); 64 m_int = new Int();
65 m_int.mValue = 2; 65 m_int.mValue = 2;
66 this._mThread.currentFrame.OpStack.Push(m_int); 66 this._mThread.currentFrame.OpStack.Push(m_int);
67 result = true; 67 result = true;
68 break; 68 break;
69 case 6: 69 case 6:
70 m_int = new Int(); 70 m_int = new Int();
71 m_int.mValue = 3; 71 m_int.mValue = 3;
72 this._mThread.currentFrame.OpStack.Push(m_int); 72 this._mThread.currentFrame.OpStack.Push(m_int);
73 break; 73 break;
74 case 7: 74 case 7:
75 m_int = new Int(); 75 m_int = new Int();
76 m_int.mValue = 4; 76 m_int.mValue = 4;
77 this._mThread.currentFrame.OpStack.Push(m_int); 77 this._mThread.currentFrame.OpStack.Push(m_int);
78 result = true; 78 result = true;
79 break; 79 break;
80 case 8: 80 case 8:
81 m_int = new Int(); 81 m_int = new Int();
82 m_int.mValue = 5; 82 m_int.mValue = 5;
83 this._mThread.currentFrame.OpStack.Push(m_int); 83 this._mThread.currentFrame.OpStack.Push(m_int);
84 result = true; 84 result = true;
85 break; 85 break;
86 case 11: 86 case 11:
87 Float m_float = new Float(); 87 Float m_float = new Float();
88 m_float.mValue = 0.0f; 88 m_float.mValue = 0.0f;
89 this._mThread.currentFrame.OpStack.Push(m_float); 89 this._mThread.currentFrame.OpStack.Push(m_float);
90 result = true; 90 result = true;
91 break; 91 break;
92 case 12: 92 case 12:
93 m_float = new Float(); 93 m_float = new Float();
94 m_float.mValue = 1.0f; 94 m_float.mValue = 1.0f;
95 this._mThread.currentFrame.OpStack.Push(m_float); 95 this._mThread.currentFrame.OpStack.Push(m_float);
96 result = true; 96 result = true;
97 break; 97 break;
98 case 13: 98 case 13:
99 m_float = new Float(); 99 m_float = new Float();
100 m_float.mValue = 2.0f; 100 m_float.mValue = 2.0f;
101 this._mThread.currentFrame.OpStack.Push(m_float); 101 this._mThread.currentFrame.OpStack.Push(m_float);
102 result = true; 102 result = true;
103 break; 103 break;
104 case 16: 104 case 16:
105 int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; 105 int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
106 Int pushInt = new Int(); 106 Int pushInt = new Int();
107 pushInt.mValue = pushvalue; 107 pushInt.mValue = pushvalue;
108 this._mThread.currentFrame.OpStack.Push(pushInt); 108 this._mThread.currentFrame.OpStack.Push(pushInt);
109 this._mThread.PC++; 109 this._mThread.PC++;
110 result = true; 110 result = true;
111 break; 111 break;
112 case 17: 112 case 17:
113 short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 113 short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
114 Int pushInt2 = new Int(); 114 Int pushInt2 = new Int();
115 pushInt2.mValue = pushvalue2; 115 pushInt2.mValue = pushvalue2;
116 this._mThread.currentFrame.OpStack.Push(pushInt2); 116 this._mThread.currentFrame.OpStack.Push(pushInt2);
117 this._mThread.PC += 2; 117 this._mThread.PC += 2;
118 result = true; 118 result = true;
119 break; 119 break;
120 case 23: 120 case 23:
121 short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); 121 short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
122 Float fload = new Float(); 122 Float fload = new Float();
123 if (this._mThread.currentFrame.LocalVariables[findex1] != null) 123 if (this._mThread.currentFrame.LocalVariables[findex1] != null)
124 { 124 {
125 if (this._mThread.currentFrame.LocalVariables[findex1] is Float) 125 if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
126 { 126 {
127 fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; 127 fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
128 this._mThread.currentFrame.OpStack.Push(fload); 128 this._mThread.currentFrame.OpStack.Push(fload);
129 } 129 }
130 } 130 }
131 this._mThread.PC++; 131 this._mThread.PC++;
132 result = true; 132 result = true;
133 break; 133 break;
134 case 26: 134 case 26:
135 if (this._mThread.currentFrame.LocalVariables[0] != null) 135 if (this._mThread.currentFrame.LocalVariables[0] != null)
136 { 136 {
137 if (this._mThread.currentFrame.LocalVariables[0] is Int) 137 if (this._mThread.currentFrame.LocalVariables[0] is Int)
138 { 138 {
139 Int newInt = new Int(); 139 Int newInt = new Int();
140 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; 140 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
141 this._mThread.currentFrame.OpStack.Push(newInt); 141 this._mThread.currentFrame.OpStack.Push(newInt);
142 } 142 }
143 } 143 }
144 result = true; 144 result = true;
145 break; 145 break;
146 case 27: 146 case 27:
147 if (this._mThread.currentFrame.LocalVariables[1] != null) 147 if (this._mThread.currentFrame.LocalVariables[1] != null)
148 { 148 {
149 if (this._mThread.currentFrame.LocalVariables[1] is Int) 149 if (this._mThread.currentFrame.LocalVariables[1] is Int)
150 { 150 {
151 Int newInt = new Int(); 151 Int newInt = new Int();
152 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; 152 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
153 this._mThread.currentFrame.OpStack.Push(newInt); 153 this._mThread.currentFrame.OpStack.Push(newInt);
154 } 154 }
155 } 155 }
156 result = true; 156 result = true;
157 break; 157 break;
158 case 34: 158 case 34:
159 if (this._mThread.currentFrame.LocalVariables[0] != null) 159 if (this._mThread.currentFrame.LocalVariables[0] != null)
160 { 160 {
161 if (this._mThread.currentFrame.LocalVariables[0] is Float) 161 if (this._mThread.currentFrame.LocalVariables[0] is Float)
162 { 162 {
163 Float newfloat = new Float(); 163 Float newfloat = new Float();
164 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; 164 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
165 this._mThread.currentFrame.OpStack.Push(newfloat); 165 this._mThread.currentFrame.OpStack.Push(newfloat);
166 } 166 }
167 } 167 }
168 result = true; 168 result = true;
169 break; 169 break;
170 case 35: 170 case 35:
171 if (this._mThread.currentFrame.LocalVariables[1] != null) 171 if (this._mThread.currentFrame.LocalVariables[1] != null)
172 { 172 {
173 if (this._mThread.currentFrame.LocalVariables[1] is Float) 173 if (this._mThread.currentFrame.LocalVariables[1] is Float)
174 { 174 {
175 Float newfloat = new Float(); 175 Float newfloat = new Float();
176 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; 176 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
177 this._mThread.currentFrame.OpStack.Push(newfloat); 177 this._mThread.currentFrame.OpStack.Push(newfloat);
178 } 178 }
179 } 179 }
180 result = true; 180 result = true;
181 break; 181 break;
182 case 36: 182 case 36:
183 if (this._mThread.currentFrame.LocalVariables[2] != null) 183 if (this._mThread.currentFrame.LocalVariables[2] != null)
184 { 184 {
185 if (this._mThread.currentFrame.LocalVariables[2] is Float) 185 if (this._mThread.currentFrame.LocalVariables[2] is Float)
186 { 186 {
187 Float newfloat = new Float(); 187 Float newfloat = new Float();
188 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; 188 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
189 this._mThread.currentFrame.OpStack.Push(newfloat); 189 this._mThread.currentFrame.OpStack.Push(newfloat);
190 } 190 }
191 } 191 }
192 result = true; 192 result = true;
193 break; 193 break;
194 case 37: 194 case 37:
195 if (this._mThread.currentFrame.LocalVariables[3] != null) 195 if (this._mThread.currentFrame.LocalVariables[3] != null)
196 { 196 {
197 if (this._mThread.currentFrame.LocalVariables[3] is Float) 197 if (this._mThread.currentFrame.LocalVariables[3] is Float)
198 { 198 {
199 Float newfloat = new Float(); 199 Float newfloat = new Float();
200 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; 200 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
201 this._mThread.currentFrame.OpStack.Push(newfloat); 201 this._mThread.currentFrame.OpStack.Push(newfloat);
202 } 202 }
203 } 203 }
204 result = true; 204 result = true;
205 break; 205 break;
206 case 56: 206 case 56:
207 short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); 207 short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
208 BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); 208 BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
209 if (fstor is Float) 209 if (fstor is Float)
210 { 210 {
211 this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; 211 this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
212 } 212 }
213 this._mThread.PC++; 213 this._mThread.PC++;
214 result = true; 214 result = true;
215 break; 215 break;
216 case 59: 216 case 59:
217 BaseType baset = this._mThread.currentFrame.OpStack.Pop(); 217 BaseType baset = this._mThread.currentFrame.OpStack.Pop();
218 if (baset is Int) 218 if (baset is Int)
219 { 219 {
220 this._mThread.currentFrame.LocalVariables[0] = (Int)baset; 220 this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
221 } 221 }
222 result = true; 222 result = true;
223 break; 223 break;
224 case 60: 224 case 60:
225 baset = this._mThread.currentFrame.OpStack.Pop(); 225 baset = this._mThread.currentFrame.OpStack.Pop();
226 if (baset is Int) 226 if (baset is Int)
227 { 227 {
228 this._mThread.currentFrame.LocalVariables[1] = (Int)baset; 228 this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
229 } 229 }
230 result = true; 230 result = true;
231 break; 231 break;
232 case 67: 232 case 67:
233 baset = this._mThread.currentFrame.OpStack.Pop(); 233 baset = this._mThread.currentFrame.OpStack.Pop();
234 if (baset is Float) 234 if (baset is Float)
235 { 235 {
236 this._mThread.currentFrame.LocalVariables[0] = (Float)baset; 236 this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
237 } 237 }
238 result = true; 238 result = true;
239 break; 239 break;
240 case 68: 240 case 68:
241 baset = this._mThread.currentFrame.OpStack.Pop(); 241 baset = this._mThread.currentFrame.OpStack.Pop();
242 if (baset is Float) 242 if (baset is Float)
243 { 243 {
244 this._mThread.currentFrame.LocalVariables[1] = (Float)baset; 244 this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
245 } 245 }
246 result = true; 246 result = true;
247 break; 247 break;
248 case 69: 248 case 69:
249 baset = this._mThread.currentFrame.OpStack.Pop(); 249 baset = this._mThread.currentFrame.OpStack.Pop();
250 if (baset is Float) 250 if (baset is Float)
251 { 251 {
252 this._mThread.currentFrame.LocalVariables[2] = (Float)baset; 252 this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
253 } 253 }
254 result = true; 254 result = true;
255 break; 255 break;
256 case 70: 256 case 70:
257 baset = this._mThread.currentFrame.OpStack.Pop(); 257 baset = this._mThread.currentFrame.OpStack.Pop();
258 if (baset is Float) 258 if (baset is Float)
259 { 259 {
260 this._mThread.currentFrame.LocalVariables[3] = (Float)baset; 260 this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
261 } 261 }
262 result = true; 262 result = true;
263 break; 263 break;
264 case 87: 264 case 87:
265 this._mThread.currentFrame.OpStack.Pop(); 265 this._mThread.currentFrame.OpStack.Pop();
266 result = true; 266 result = true;
267 break; 267 break;
268 case 98: 268 case 98:
269 BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); 269 BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
270 BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); 270 BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
271 if (bf1 is Float && bf2 is Float) 271 if (bf1 is Float && bf2 is Float)
272 { 272 {
273 Float nflt = new Float(); 273 Float nflt = new Float();
274 nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; 274 nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
275 this._mThread.currentFrame.OpStack.Push(nflt); 275 this._mThread.currentFrame.OpStack.Push(nflt);
276 } 276 }
277 result = true; 277 result = true;
278 break; 278 break;
279 case 102: 279 case 102:
280 BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); 280 BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
281 BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); 281 BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
282 if (bsf1 is Float && bsf2 is Float) 282 if (bsf1 is Float && bsf2 is Float)
283 { 283 {
284 Float resf = new Float(); 284 Float resf = new Float();
285 resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; 285 resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
286 this._mThread.currentFrame.OpStack.Push(resf); 286 this._mThread.currentFrame.OpStack.Push(resf);
287 } 287 }
288 result = true; 288 result = true;
289 break; 289 break;
290 case 104: //check the order of the two values off the stack is correct 290 case 104: //check the order of the two values off the stack is correct
291 BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); 291 BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
292 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); 292 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
293 if (bs1 is Int && bs2 is Int) 293 if (bs1 is Int && bs2 is Int)
294 { 294 {
295 Int nInt = new Int(); 295 Int nInt = new Int();
296 nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; 296 nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
297 this._mThread.currentFrame.OpStack.Push(nInt); 297 this._mThread.currentFrame.OpStack.Push(nInt);
298 } 298 }
299 result = true; 299 result = true;
300 break; 300 break;
301 case 132: 301 case 132:
302 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) 302 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
303 { 303 {
304 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) 304 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
305 { 305 {
306 ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; 306 ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
307 } 307 }
308 } 308 }
309 this._mThread.PC += 2; 309 this._mThread.PC += 2;
310 result = true; 310 result = true;
311 break; 311 break;
312 case 139: 312 case 139:
313 BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); 313 BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
314 if (conv1 is Float) 314 if (conv1 is Float)
315 { 315 {
316 Int newconv = new Int(); 316 Int newconv = new Int();
317 newconv.mValue = (int)((Float)conv1).mValue; 317 newconv.mValue = (int)((Float)conv1).mValue;
318 this._mThread.currentFrame.OpStack.Push(newconv); 318 this._mThread.currentFrame.OpStack.Push(newconv);
319 } 319 }
320 result = true; 320 result = true;
321 break; 321 break;
322 case 149: 322 case 149:
323 BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); 323 BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
324 BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); 324 BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
325 if (flcom1 is Float && flcom2 is Float) 325 if (flcom1 is Float && flcom2 is Float)
326 { 326 {
327 Int compres = new Int(); 327 Int compres = new Int();
328 if (((Float)flcom1).mValue < ((Float)flcom2).mValue) 328 if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
329 { 329 {
330 compres.mValue = -1; 330 compres.mValue = -1;
331 } 331 }
332 else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) 332 else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
333 { 333 {
334 compres.mValue = 1; 334 compres.mValue = 1;
335 } 335 }
336 else 336 else
337 { 337 {
338 compres.mValue = 0; 338 compres.mValue = 0;
339 } 339 }
340 this._mThread.currentFrame.OpStack.Push(compres); 340 this._mThread.currentFrame.OpStack.Push(compres);
341 } 341 }
342 result = true; 342 result = true;
343 break; 343 break;
344 case 158: 344 case 158:
345 short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 345 short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
346 BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); 346 BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
347 if (comp1 is Int) 347 if (comp1 is Int)
348 { 348 {
349 if (((Int)comp1).mValue <= 0) 349 if (((Int)comp1).mValue <= 0)
350 { 350 {
351 this._mThread.PC += -1 + compareoffset1; 351 this._mThread.PC += -1 + compareoffset1;
352 } 352 }
353 else 353 else
354 { 354 {
355 this._mThread.PC += 2; 355 this._mThread.PC += 2;
356 } 356 }
357 } 357 }
358 else 358 else
359 { 359 {
360 this._mThread.PC += 2; 360 this._mThread.PC += 2;
361 } 361 }
362 result = true; 362 result = true;
363 break; 363 break;
364 case 162: 364 case 162:
365 short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 365 short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
366 BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); 366 BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
367 BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); 367 BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
368 if (bc1 is Int && bc2 is Int) 368 if (bc1 is Int && bc2 is Int)
369 { 369 {
370 //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); 370 //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
371 if (((Int)bc1).mValue >= ((Int)bc2).mValue) 371 if (((Int)bc1).mValue >= ((Int)bc2).mValue)
372 { 372 {
373 // Console.WriteLine("branch compare true , offset is " +compareoffset); 373 // Console.WriteLine("branch compare true , offset is " +compareoffset);
374 // Console.WriteLine("current PC is " + this._mThread.PC); 374 // Console.WriteLine("current PC is " + this._mThread.PC);
375 this._mThread.PC += -1 + compareoffset; 375 this._mThread.PC += -1 + compareoffset;
376 //Console.WriteLine("new PC is " + this._mThread.PC); 376 //Console.WriteLine("new PC is " + this._mThread.PC);
377 } 377 }
378 else 378 else
379 { 379 {
380 //Console.WriteLine("branch compare false"); 380 //Console.WriteLine("branch compare false");
381 this._mThread.PC += 2; 381 this._mThread.PC += 2;
382 } 382 }
383 } 383 }
384 else 384 else
385 { 385 {
386 this._mThread.PC += 2; 386 this._mThread.PC += 2;
387 } 387 }
388 result = true; 388 result = true;
389 break; 389 break;
390 case 164: 390 case 164:
391 short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); 391 short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
392 BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); 392 BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
393 BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); 393 BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
394 if (bcl1 is Int && bcl2 is Int) 394 if (bcl1 is Int && bcl2 is Int)
395 { 395 {
396 //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); 396 //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
397 if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) 397 if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
398 { 398 {
399 // Console.WriteLine("branch compare true , offset is " + compareloffset); 399 // Console.WriteLine("branch compare true , offset is " + compareloffset);
400 // Console.WriteLine("current PC is " + this._mThread.PC); 400 // Console.WriteLine("current PC is " + this._mThread.PC);
401 this._mThread.PC += -1 + compareloffset; 401 this._mThread.PC += -1 + compareloffset;
402 // Console.WriteLine("new PC is " + this._mThread.PC); 402 // Console.WriteLine("new PC is " + this._mThread.PC);
403 } 403 }
404 else 404 else
405 { 405 {
406 //Console.WriteLine("branch compare false"); 406 //Console.WriteLine("branch compare false");
407 this._mThread.PC += 2; 407 this._mThread.PC += 2;
408 } 408 }
409 } 409 }
410 else 410 else
411 { 411 {
412 this._mThread.PC += 2; 412 this._mThread.PC += 2;
413 } 413 }
414 result = true; 414 result = true;
415 break; 415 break;
416 case 167: 416 case 167:
417 short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); 417 short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
418 this._mThread.PC += -1 + offset; 418 this._mThread.PC += -1 + offset;
419 result = true; 419 result = true;
420 break; 420 break;
421 } 421 }
422 422
423 return result; 423 return result;
424 } 424 }
425 } 425 }
426 } 426 }
427} 427}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs
index e2e2b7c..6b85fcc 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs
@@ -1,96 +1,96 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; 32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33using OpenSim.Framework.Interfaces; 33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36 36
37namespace OpenSim.Region.Scripting.EmbeddedJVM 37namespace OpenSim.Region.Scripting.EmbeddedJVM
38{ 38{
39 partial class Thread 39 partial class Thread
40 { 40 {
41 private partial class Interpreter 41 private partial class Interpreter
42 { 42 {
43 private bool IsMethodOpCode(byte opcode) 43 private bool IsMethodOpCode(byte opcode)
44 { 44 {
45 bool result = false; 45 bool result = false;
46 switch (opcode) 46 switch (opcode)
47 { 47 {
48 case 184: 48 case 184:
49 short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); 49 short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
50 if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) 50 if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
51 { 51 {
52 string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; 52 string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value;
53 string typeparam = ""; 53 string typeparam = "";
54 string typereturn = ""; 54 string typereturn = "";
55 int firstbrak = 0; 55 int firstbrak = 0;
56 int secondbrak = 0; 56 int secondbrak = 0;
57 firstbrak = typ.LastIndexOf('('); 57 firstbrak = typ.LastIndexOf('(');
58 secondbrak = typ.LastIndexOf(')'); 58 secondbrak = typ.LastIndexOf(')');
59 typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); 59 typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
60 typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); 60 typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
61 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) 61 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
62 { 62 {
63 //calling a method in this class 63 //calling a method in this class
64 if (typeparam.Length == 0) 64 if (typeparam.Length == 0)
65 { 65 {
66 this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); 66 this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2));
67 } 67 }
68 else 68 else
69 { 69 {
70 this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); 70 this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2));
71 } 71 }
72 } 72 }
73 else 73 else
74 { 74 {
75 //calling a method of a different class 75 //calling a method of a different class
76 76
77 // OpenSimAPI Class 77 // OpenSimAPI Class
78 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") 78 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
79 { 79 {
80 this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null); 80 this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null);
81 } 81 }
82 } 82 }
83 } 83 }
84 else 84 else
85 { 85 {
86 this._mThread.PC += 2; 86 this._mThread.PC += 2;
87 } 87 }
88 result = true; 88 result = true;
89 break; 89 break;
90 } 90 }
91 91
92 return result; 92 return result;
93 } 93 }
94 } 94 }
95 } 95 }
96} 96}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs
index 6444776..3c18a11 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs
@@ -1,40 +1,40 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 partial class Thread 34 partial class Thread
35 { 35 {
36 private partial class Interpreter 36 private partial class Interpreter
37 { 37 {
38 } 38 }
39 } 39 }
40} 40}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs
index d44f315..9961cbd 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs
@@ -1,135 +1,135 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; 32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33 33
34namespace OpenSim.Region.Scripting.EmbeddedJVM 34namespace OpenSim.Region.Scripting.EmbeddedJVM
35{ 35{
36 partial class Thread 36 partial class Thread
37 { 37 {
38 private partial class Interpreter 38 private partial class Interpreter
39 { 39 {
40 private Thread _mThread; 40 private Thread _mThread;
41 41
42 public Interpreter(Thread parentThread) 42 public Interpreter(Thread parentThread)
43 { 43 {
44 _mThread = parentThread; 44 _mThread = parentThread;
45 } 45 }
46 46
47 public bool Excute() 47 public bool Excute()
48 { 48 {
49 bool run = true; 49 bool run = true;
50 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; 50 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
51 // Console.WriteLine("opCode is: " + currentOpCode); 51 // Console.WriteLine("opCode is: " + currentOpCode);
52 bool handled = false; 52 bool handled = false;
53 53
54 handled = this.IsLogicOpCode(currentOpCode); 54 handled = this.IsLogicOpCode(currentOpCode);
55 if (!handled) 55 if (!handled)
56 { 56 {
57 handled = this.IsMethodOpCode(currentOpCode); 57 handled = this.IsMethodOpCode(currentOpCode);
58 } 58 }
59 if (!handled) 59 if (!handled)
60 { 60 {
61 if (currentOpCode == 172) 61 if (currentOpCode == 172)
62 { 62 {
63 if (this._mThread.stack.StackFrames.Count > 1) 63 if (this._mThread.stack.StackFrames.Count > 1)
64 { 64 {
65 Console.WriteLine("returning int from function"); 65 Console.WriteLine("returning int from function");
66 int retPC1 = this._mThread.currentFrame.ReturnPC; 66 int retPC1 = this._mThread.currentFrame.ReturnPC;
67 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); 67 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
68 this._mThread.stack.StackFrames.Pop(); 68 this._mThread.stack.StackFrames.Pop();
69 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); 69 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
70 this._mThread.PC = retPC1; 70 this._mThread.PC = retPC1;
71 if (bas1 is Int) 71 if (bas1 is Int)
72 { 72 {
73 this._mThread.currentFrame.OpStack.Push((Int)bas1); 73 this._mThread.currentFrame.OpStack.Push((Int)bas1);
74 } 74 }
75 } 75 }
76 else 76 else
77 { 77 {
78 // Console.WriteLine("No parent function so ending program"); 78 // Console.WriteLine("No parent function so ending program");
79 this._mThread.stack.StackFrames.Pop(); 79 this._mThread.stack.StackFrames.Pop();
80 run = false; 80 run = false;
81 } 81 }
82 handled = true; 82 handled = true;
83 } 83 }
84 if (currentOpCode == 174) 84 if (currentOpCode == 174)
85 { 85 {
86 if (this._mThread.stack.StackFrames.Count > 1) 86 if (this._mThread.stack.StackFrames.Count > 1)
87 { 87 {
88 Console.WriteLine("returning float from function"); 88 Console.WriteLine("returning float from function");
89 int retPC1 = this._mThread.currentFrame.ReturnPC; 89 int retPC1 = this._mThread.currentFrame.ReturnPC;
90 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); 90 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
91 this._mThread.stack.StackFrames.Pop(); 91 this._mThread.stack.StackFrames.Pop();
92 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); 92 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
93 this._mThread.PC = retPC1; 93 this._mThread.PC = retPC1;
94 if (bas1 is Float) 94 if (bas1 is Float)
95 { 95 {
96 this._mThread.currentFrame.OpStack.Push((Float)bas1); 96 this._mThread.currentFrame.OpStack.Push((Float)bas1);
97 } 97 }
98 } 98 }
99 else 99 else
100 { 100 {
101 // Console.WriteLine("No parent function so ending program"); 101 // Console.WriteLine("No parent function so ending program");
102 this._mThread.stack.StackFrames.Pop(); 102 this._mThread.stack.StackFrames.Pop();
103 run = false; 103 run = false;
104 } 104 }
105 handled = true; 105 handled = true;
106 } 106 }
107 if (currentOpCode == 177) 107 if (currentOpCode == 177)
108 { 108 {
109 if (this._mThread.stack.StackFrames.Count > 1) 109 if (this._mThread.stack.StackFrames.Count > 1)
110 { 110 {
111 Console.WriteLine("returning from function"); 111 Console.WriteLine("returning from function");
112 int retPC = this._mThread.currentFrame.ReturnPC; 112 int retPC = this._mThread.currentFrame.ReturnPC;
113 this._mThread.stack.StackFrames.Pop(); 113 this._mThread.stack.StackFrames.Pop();
114 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); 114 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
115 this._mThread.PC = retPC; 115 this._mThread.PC = retPC;
116 } 116 }
117 else 117 else
118 { 118 {
119 // Console.WriteLine("No parent function so ending program"); 119 // Console.WriteLine("No parent function so ending program");
120 this._mThread.stack.StackFrames.Pop(); 120 this._mThread.stack.StackFrames.Pop();
121 run = false; 121 run = false;
122 } 122 }
123 handled = true; 123 handled = true;
124 } 124 }
125 } 125 }
126 if (!handled) 126 if (!handled)
127 { 127 {
128 Console.WriteLine("opcode " + currentOpCode + " not been handled "); 128 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
129 } 129 }
130 return run; 130 return run;
131 131
132 } 132 }
133 } 133 }
134 } 134 }
135} 135}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs
index addb6ff..7174975 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs
@@ -1,45 +1,45 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 public class MainMemory 34 public class MainMemory
35 { 35 {
36 public Heap HeapArea; 36 public Heap HeapArea;
37 public MethodMemory MethodArea; 37 public MethodMemory MethodArea;
38 38
39 public MainMemory() 39 public MainMemory()
40 { 40 {
41 MethodArea = new MethodMemory(); 41 MethodArea = new MethodMemory();
42 HeapArea = new Heap(); 42 HeapArea = new Heap();
43 } 43 }
44 } 44 }
45} 45}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs
index 7d69e91..5f29091 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs
@@ -1,46 +1,46 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 public class MethodMemory 34 public class MethodMemory
35 { 35 {
36 public byte[] MethodBuffer; 36 public byte[] MethodBuffer;
37 public List<ClassRecord> Classes = new List<ClassRecord>(); 37 public List<ClassRecord> Classes = new List<ClassRecord>();
38 public int NextMethodPC = 0; 38 public int NextMethodPC = 0;
39 public int Methodcount = 0; 39 public int Methodcount = 0;
40 40
41 public MethodMemory() 41 public MethodMemory()
42 { 42 {
43 MethodBuffer = new byte[20000]; 43 MethodBuffer = new byte[20000];
44 } 44 }
45 } 45 }
46} 46}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs
index 6a0a1a4..8acb2bd 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs
@@ -1,37 +1,37 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 public class Object 34 public class Object
35 { 35 {
36 } 36 }
37} 37}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs
index 74f0a7f..7c12678 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs
@@ -1,42 +1,42 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31 31
32namespace OpenSim.Region.Scripting.EmbeddedJVM 32namespace OpenSim.Region.Scripting.EmbeddedJVM
33{ 33{
34 public class Stack 34 public class Stack
35 { 35 {
36 public Stack<StackFrame> StackFrames = new Stack<StackFrame>(); 36 public Stack<StackFrame> StackFrames = new Stack<StackFrame>();
37 37
38 public Stack() 38 public Stack()
39 { 39 {
40 } 40 }
41 } 41 }
42} 42}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs
index 1072395..76257b8 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs
@@ -1,49 +1,49 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32 32
33namespace OpenSim.Region.Scripting.EmbeddedJVM 33namespace OpenSim.Region.Scripting.EmbeddedJVM
34{ 34{
35 public class StackFrame 35 public class StackFrame
36 { 36 {
37 public BaseType[] LocalVariables; 37 public BaseType[] LocalVariables;
38 public Stack<BaseType> OpStack = new Stack<BaseType>(); 38 public Stack<BaseType> OpStack = new Stack<BaseType>();
39 39
40 public int ReturnPC = 0; 40 public int ReturnPC = 0;
41 public ClassRecord CallingClass = null; 41 public ClassRecord CallingClass = null;
42 42
43 public StackFrame() 43 public StackFrame()
44 { 44 {
45 LocalVariables = new BaseType[20]; 45 LocalVariables = new BaseType[20];
46 } 46 }
47 47
48 } 48 }
49} 49}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs
index 59f3042..eda2640 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs
@@ -1,119 +1,119 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using OpenSim.Region.Scripting.EmbeddedJVM.Types; 31using OpenSim.Region.Scripting.EmbeddedJVM.Types;
32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; 32using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36using OpenSim.Region.Scripting; 36using OpenSim.Region.Scripting;
37 37
38namespace OpenSim.Region.Scripting.EmbeddedJVM 38namespace OpenSim.Region.Scripting.EmbeddedJVM
39{ 39{
40 public partial class Thread 40 public partial class Thread
41 { 41 {
42 // Is this smart? 42 // Is this smart?
43 public static MainMemory GlobalMemory; 43 public static MainMemory GlobalMemory;
44 public static Scene World; 44 public static Scene World;
45 private int PC = 0; 45 private int PC = 0;
46 private Stack stack; 46 private Stack stack;
47 private Interpreter mInterpreter; 47 private Interpreter mInterpreter;
48 public ClassRecord currentClass; 48 public ClassRecord currentClass;
49 public ClassInstance currentInstance; 49 public ClassInstance currentInstance;
50 private StackFrame currentFrame; 50 private StackFrame currentFrame;
51 public int excutionCounter = 0; 51 public int excutionCounter = 0;
52 public bool running = false; 52 public bool running = false;
53 53
54 public ScriptInfo scriptInfo; 54 public ScriptInfo scriptInfo;
55 55
56 public Thread() 56 public Thread()
57 { 57 {
58 this.mInterpreter = new Interpreter(this); 58 this.mInterpreter = new Interpreter(this);
59 this.stack = new Stack(); 59 this.stack = new Stack();
60 } 60 }
61 61
62 public void SetPC(int methodpointer) 62 public void SetPC(int methodpointer)
63 { 63 {
64 //Console.WriteLine("Thread PC has been set to " + methodpointer); 64 //Console.WriteLine("Thread PC has been set to " + methodpointer);
65 PC = methodpointer; 65 PC = methodpointer;
66 } 66 }
67 67
68 public void StartMethod(ClassRecord rec, string methName) 68 public void StartMethod(ClassRecord rec, string methName)
69 { 69 {
70 currentFrame = new StackFrame(); 70 currentFrame = new StackFrame();
71 this.stack.StackFrames.Push(currentFrame); 71 this.stack.StackFrames.Push(currentFrame);
72 this.currentClass = rec; 72 this.currentClass = rec;
73 currentClass.StartMethod(this, methName); 73 currentClass.StartMethod(this, methName);
74 } 74 }
75 75
76 public void StartMethod( string methName) 76 public void StartMethod( string methName)
77 { 77 {
78 currentFrame = new StackFrame(); 78 currentFrame = new StackFrame();
79 this.stack.StackFrames.Push(currentFrame); 79 this.stack.StackFrames.Push(currentFrame);
80 currentClass.StartMethod(this, methName); 80 currentClass.StartMethod(this, methName);
81 } 81 }
82 82
83 public void JumpToStaticVoidMethod(string methName, int returnPC) 83 public void JumpToStaticVoidMethod(string methName, int returnPC)
84 { 84 {
85 currentFrame = new StackFrame(); 85 currentFrame = new StackFrame();
86 currentFrame.ReturnPC = returnPC; 86 currentFrame.ReturnPC = returnPC;
87 this.stack.StackFrames.Push(currentFrame); 87 this.stack.StackFrames.Push(currentFrame);
88 currentClass.StartMethod(this, methName); 88 currentClass.StartMethod(this, methName);
89 } 89 }
90 90
91 public void JumpToStaticParamMethod(string methName, string param, int returnPC) 91 public void JumpToStaticParamMethod(string methName, string param, int returnPC)
92 { 92 {
93 if (param == "I") 93 if (param == "I")
94 { 94 {
95 BaseType bs1 = currentFrame.OpStack.Pop(); 95 BaseType bs1 = currentFrame.OpStack.Pop();
96 currentFrame = new StackFrame(); 96 currentFrame = new StackFrame();
97 currentFrame.ReturnPC = returnPC; 97 currentFrame.ReturnPC = returnPC;
98 this.stack.StackFrames.Push(currentFrame); 98 this.stack.StackFrames.Push(currentFrame);
99 currentFrame.LocalVariables[0] = ((Int)bs1); 99 currentFrame.LocalVariables[0] = ((Int)bs1);
100 currentClass.StartMethod(this, methName); 100 currentClass.StartMethod(this, methName);
101 } 101 }
102 if (param == "F") 102 if (param == "F")
103 { 103 {
104 104
105 } 105 }
106 } 106 }
107 107
108 public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) 108 public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
109 { 109 {
110 110
111 } 111 }
112 112
113 public bool Excute() 113 public bool Excute()
114 { 114 {
115 excutionCounter++; 115 excutionCounter++;
116 return this.mInterpreter.Excute(); 116 return this.mInterpreter.Excute();
117 } 117 }
118 } 118 }
119} 119}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs
index a884e2b..58cdf49 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs
@@ -1,29 +1,29 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Region.Scripting; 5using OpenSim.Region.Scripting;
6using OpenSim.Region.Scripting.EmbeddedJVM; 6using OpenSim.Region.Scripting.EmbeddedJVM;
7 7
8namespace OpenSim.Region.Scripting 8namespace OpenSim.Region.Scripting
9{ 9{
10 public class JavaEngine : IScriptCompiler 10 public class JavaEngine : IScriptCompiler
11 { 11 {
12 public string FileExt() 12 public string FileExt()
13 { 13 {
14 return ".java"; 14 return ".java";
15 } 15 }
16 16
17 public Dictionary<string, IScript> compile(string filename) 17 public Dictionary<string, IScript> compile(string filename)
18 { 18 {
19 JVMScript script = new JVMScript(); 19 JVMScript script = new JVMScript();
20 Dictionary<string, IScript> returns = new Dictionary<string, IScript>(); 20 Dictionary<string, IScript> returns = new Dictionary<string, IScript>();
21 21
22 script.LoadScript(filename); 22 script.LoadScript(filename);
23 23
24 returns.Add(filename, script); 24 returns.Add(filename, script);
25 25
26 return returns; 26 return returns;
27 } 27 }
28 } 28 }
29} 29}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
index 8b38951..78c6f67 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
@@ -1,170 +1,170 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using System.IO; 31using System.IO;
32using System.Threading; 32using System.Threading;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Utilities; 35using OpenSim.Framework.Utilities;
36using OpenSim.Region.Scripting; 36using OpenSim.Region.Scripting;
37using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
38 38
39namespace OpenSim.Region.Scripting.EmbeddedJVM 39namespace OpenSim.Region.Scripting.EmbeddedJVM
40{ 40{
41 public class JVMScript : IScript 41 public class JVMScript : IScript
42 { 42 {
43 private List<Thread> _threads = new List<Thread>(); 43 private List<Thread> _threads = new List<Thread>();
44 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>(); 44 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
45 private MainMemory _mainMemory; 45 private MainMemory _mainMemory;
46 46
47 ScriptInfo scriptInfo; 47 ScriptInfo scriptInfo;
48 48
49 public void Initialise(ScriptInfo info) 49 public void Initialise(ScriptInfo info)
50 { 50 {
51 scriptInfo = info; 51 scriptInfo = info;
52 52
53 _mainMemory = new MainMemory(); 53 _mainMemory = new MainMemory();
54 Thread.GlobalMemory = this._mainMemory; 54 Thread.GlobalMemory = this._mainMemory;
55 Thread.World = info.world; 55 Thread.World = info.world;
56 CompileScript(); 56 CompileScript();
57 57
58 scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); 58 scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
59 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); 59 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
60 } 60 }
61 61
62 void events_OnNewPresence(ScenePresence presence) 62 void events_OnNewPresence(ScenePresence presence)
63 { 63 {
64 for (int i = 0; i < this._threads.Count; i++) 64 for (int i = 0; i < this._threads.Count; i++)
65 { 65 {
66 if (!this._threads[i].running) 66 if (!this._threads[i].running)
67 { 67 {
68 this._threads[i].StartMethod("OnNewPresence"); 68 this._threads[i].StartMethod("OnNewPresence");
69 bool run = true; 69 bool run = true;
70 while (run) 70 while (run)
71 { 71 {
72 run = this._threads[i].Excute(); 72 run = this._threads[i].Excute();
73 } 73 }
74 } 74 }
75 } 75 }
76 } 76 }
77 77
78 void events_OnFrame() 78 void events_OnFrame()
79 { 79 {
80 for (int i = 0; i < this._threads.Count; i++) 80 for (int i = 0; i < this._threads.Count; i++)
81 { 81 {
82 if (!this._threads[i].running) 82 if (!this._threads[i].running)
83 { 83 {
84 this._threads[i].StartMethod("OnFrame"); 84 this._threads[i].StartMethod("OnFrame");
85 bool run = true; 85 bool run = true;
86 while (run) 86 while (run)
87 { 87 {
88 run = this._threads[i].Excute(); 88 run = this._threads[i].Excute();
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 public string getName() 94 public string getName()
95 { 95 {
96 return "JVM Scripting Engine"; 96 return "JVM Scripting Engine";
97 } 97 }
98 98
99 public void LoadScript(string script) 99 public void LoadScript(string script)
100 { 100 {
101 Console.WriteLine("OpenSimJVM - loading new script: " + script); 101 Console.WriteLine("OpenSimJVM - loading new script: " + script);
102 CompileInfo comp = new CompileInfo(); 102 CompileInfo comp = new CompileInfo();
103 comp.script = script; 103 comp.script = script;
104 comp.scriptName = script; 104 comp.scriptName = script;
105 this.CompileScripts.Enqueue(comp); 105 this.CompileScripts.Enqueue(comp);
106 } 106 }
107 107
108 public void CompileScript() 108 public void CompileScript()
109 { 109 {
110 CompileInfo comp = this.CompileScripts.Dequeue(); 110 CompileInfo comp = this.CompileScripts.Dequeue();
111 string script = comp.script; 111 string script = comp.script;
112 string scriptName = comp.scriptName; 112 string scriptName = comp.scriptName;
113 try 113 try
114 { 114 {
115 //need to compile the script into a java class file 115 //need to compile the script into a java class file
116 116
117 //first save it to a java source file 117 //first save it to a java source file
118 TextWriter tw = new StreamWriter(scriptName + ".java"); 118 TextWriter tw = new StreamWriter(scriptName + ".java");
119 tw.WriteLine(script); 119 tw.WriteLine(script);
120 tw.Close(); 120 tw.Close();
121 121
122 //now compile 122 //now compile
123 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); 123 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
124 // psi.RedirectStandardOutput = true; 124 // psi.RedirectStandardOutput = true;
125 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 125 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
126 psi.UseShellExecute = false; 126 psi.UseShellExecute = false;
127 127
128 System.Diagnostics.Process javacomp; 128 System.Diagnostics.Process javacomp;
129 javacomp = System.Diagnostics.Process.Start(psi); 129 javacomp = System.Diagnostics.Process.Start(psi);
130 javacomp.WaitForExit(); 130 javacomp.WaitForExit();
131 131
132 132
133 //now load in class file 133 //now load in class file
134 ClassRecord class1 = new ClassRecord(); 134 ClassRecord class1 = new ClassRecord();
135 class1.LoadClassFromFile(scriptName + ".class"); 135 class1.LoadClassFromFile(scriptName + ".class");
136 class1.PrintToConsole(); 136 class1.PrintToConsole();
137 //Console.WriteLine(); 137 //Console.WriteLine();
138 this._mainMemory.MethodArea.Classes.Add(class1); 138 this._mainMemory.MethodArea.Classes.Add(class1);
139 class1.AddMethodsToMemory(this._mainMemory.MethodArea); 139 class1.AddMethodsToMemory(this._mainMemory.MethodArea);
140 140
141 Thread newThread = new Thread(); 141 Thread newThread = new Thread();
142 this._threads.Add(newThread); 142 this._threads.Add(newThread);
143 newThread.currentClass = class1; 143 newThread.currentClass = class1;
144 newThread.scriptInfo = scriptInfo; 144 newThread.scriptInfo = scriptInfo;
145 145
146 //now delete the created files 146 //now delete the created files
147 System.IO.File.Delete(scriptName + ".java"); 147 System.IO.File.Delete(scriptName + ".java");
148 System.IO.File.Delete(scriptName + ".class"); 148 System.IO.File.Delete(scriptName + ".class");
149 //this.OnFrame(); 149 //this.OnFrame();
150 } 150 }
151 catch (Exception e) 151 catch (Exception e)
152 { 152 {
153 Console.WriteLine("exception"); 153 Console.WriteLine("exception");
154 Console.WriteLine(e.StackTrace); 154 Console.WriteLine(e.StackTrace);
155 Console.WriteLine(e.Message); 155 Console.WriteLine(e.Message);
156 } 156 }
157 } 157 }
158 158
159 private class CompileInfo 159 private class CompileInfo
160 { 160 {
161 public string script; 161 public string script;
162 public string scriptName; 162 public string scriptName;
163 163
164 public CompileInfo() 164 public CompileInfo()
165 { 165 {
166 166
167 } 167 }
168 } 168 }
169 } 169 }
170} 170}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
index 40e2e22..0c4d623 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
@@ -1,10 +1,10 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types
6{ 6{
7 public class ArrayReference :BaseType 7 public class ArrayReference :BaseType
8 { 8 {
9 } 9 }
10} 10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
index 4ee1720..7fc0a4f 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
@@ -1,10 +1,10 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types
6{ 6{
7 public class BaseType : Object 7 public class BaseType : Object
8 { 8 {
9 } 9 }
10} 10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
index 75d8e41..7718765 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
@@ -1,16 +1,16 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types
6{ 6{
7 public class ObjectReference : BaseType 7 public class ObjectReference : BaseType
8 { 8 {
9 public ushort Reference; 9 public ushort Reference;
10 10
11 public ObjectReference() 11 public ObjectReference()
12 { 12 {
13 13
14 } 14 }
15 } 15 }
16} 16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
index f5446dc..5a7b780 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
@@ -1,10 +1,10 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{ 6{
7 public class Byte : BaseType 7 public class Byte : BaseType
8 { 8 {
9 } 9 }
10} 10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
index 89824b4..c87ee8f 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
@@ -1,10 +1,10 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{ 6{
7 public class Char : BaseType 7 public class Char : BaseType
8 { 8 {
9 } 9 }
10} 10}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
index 2638c20..982e748 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
@@ -1,16 +1,16 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{ 6{
7 public class Float : BaseType 7 public class Float : BaseType
8 { 8 {
9 public float mValue = 0; 9 public float mValue = 0;
10 10
11 public Float() 11 public Float()
12 { 12 {
13 13
14 } 14 }
15 } 15 }
16} 16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
index 0155e72..073a9b3 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
@@ -1,16 +1,16 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes 5namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{ 6{
7 public class Int : BaseType 7 public class Int : BaseType
8 { 8 {
9 public int mValue = 0; 9 public int mValue = 0;
10 10
11 public Int() 11 public Int()
12 { 12 {
13 13
14 } 14 }
15 } 15 }
16} 16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs
index 8b957d3..012a00e 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs
@@ -1,140 +1,140 @@
1using System; 1using System;
2using System.Reflection; 2using System.Reflection;
3using System.Reflection.Emit; 3using System.Reflection.Emit;
4using System.Threading; 4using System.Threading;
5 5
6using OpenSim.Region.Scripting; 6using OpenSim.Region.Scripting;
7 7
8namespace OpenSim.ScriptEngines.LSL 8namespace OpenSim.ScriptEngines.LSL
9{ 9{
10 10
11 11
12 public class Engine 12 public class Engine
13 { 13 {
14 public void Start(ScriptInfo WorldAPI) 14 public void Start(ScriptInfo WorldAPI)
15 { 15 {
16 16
17 17
18 18
19 // Create Assembly Name 19 // Create Assembly Name
20 AssemblyName asmName = new AssemblyName(); 20 AssemblyName asmName = new AssemblyName();
21 asmName.Name = "TestAssembly"; 21 asmName.Name = "TestAssembly";
22 22
23 // Create Assembly 23 // Create Assembly
24 AssemblyBuilder asmBuilder = 24 AssemblyBuilder asmBuilder =
25 Thread.GetDomain().DefineDynamicAssembly 25 Thread.GetDomain().DefineDynamicAssembly
26 (asmName, AssemblyBuilderAccess.RunAndSave); 26 (asmName, AssemblyBuilderAccess.RunAndSave);
27 27
28 // Create a module (and save to disk) 28 // Create a module (and save to disk)
29 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule 29 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule
30 (asmName.Name, asmName.Name + ".dll"); 30 (asmName.Name, asmName.Name + ".dll");
31 31
32 // Create a Class (/Type) 32 // Create a Class (/Type)
33 TypeBuilder typeBuilder = modBuilder.DefineType( 33 TypeBuilder typeBuilder = modBuilder.DefineType(
34 "MyClass", 34 "MyClass",
35 TypeAttributes.Public, 35 TypeAttributes.Public,
36 typeof(object), 36 typeof(object),
37 new Type[] { typeof(LSL_CLRInterface.LSLScript) }); 37 new Type[] { typeof(LSL_CLRInterface.LSLScript) });
38 38
39 39
40 40
41 /* 41 /*
42 * Generate the IL itself 42 * Generate the IL itself
43 */ 43 */
44 44
45 GenerateIL(WorldAPI, typeBuilder); 45 GenerateIL(WorldAPI, typeBuilder);
46 46
47 47
48 /* 48 /*
49 * Done generating, create a type and run it. 49 * Done generating, create a type and run it.
50 */ 50 */
51 51
52 // Create type object for the class (after defining fields and methods) 52 // Create type object for the class (after defining fields and methods)
53 Type type = typeBuilder.CreateType(); 53 Type type = typeBuilder.CreateType();
54 54
55 asmBuilder.Save("TestAssembly.dll"); 55 asmBuilder.Save("TestAssembly.dll");
56 56
57 // Create an instance we can play with 57 // Create an instance we can play with
58 //LSLScript hello = (LSLScript)Activator.CreateInstance(type); 58 //LSLScript hello = (LSLScript)Activator.CreateInstance(type);
59 LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); 59 LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type);
60 60
61 // Play with it 61 // Play with it
62 MyScript.event_state_entry("Test"); 62 MyScript.event_state_entry("Test");
63 } 63 }
64 64
65 private void GenerateIL(ScriptInfo WorldAPI, TypeBuilder typeBuilder) 65 private void GenerateIL(ScriptInfo WorldAPI, TypeBuilder typeBuilder)
66 { 66 {
67 67
68 68
69 // For debug 69 // For debug
70 LSO_Parser LSOP = new LSO_Parser(); 70 LSO_Parser LSOP = new LSO_Parser();
71 LSOP.ParseFile("LSO\\CloseToDefault.lso", WorldAPI, ref typeBuilder); 71 LSOP.ParseFile("LSO\\CloseToDefault.lso", WorldAPI, ref typeBuilder);
72 return; 72 return;
73 73
74 74
75 // Override a Method / Function 75 // Override a Method / Function
76 MethodBuilder methodBuilder = typeBuilder.DefineMethod("event_state_entry", 76 MethodBuilder methodBuilder = typeBuilder.DefineMethod("event_state_entry",
77 MethodAttributes.Private | MethodAttributes.Virtual, 77 MethodAttributes.Private | MethodAttributes.Virtual,
78 typeof(void), 78 typeof(void),
79 new Type[] { typeof(object) }); 79 new Type[] { typeof(object) });
80 80
81 typeBuilder.DefineMethodOverride(methodBuilder, 81 typeBuilder.DefineMethodOverride(methodBuilder,
82 typeof(LSL_CLRInterface.LSLScript).GetMethod("event_state_entry")); 82 typeof(LSL_CLRInterface.LSLScript).GetMethod("event_state_entry"));
83 83
84 // Create the IL generator 84 // Create the IL generator
85 ILGenerator il = methodBuilder.GetILGenerator(); 85 ILGenerator il = methodBuilder.GetILGenerator();
86 86
87 87
88 /* 88 /*
89 * TRY 89 * TRY
90 */ 90 */
91 il.BeginExceptionBlock(); 91 il.BeginExceptionBlock();
92 92
93 // Push "Hello World!" string to stack 93 // Push "Hello World!" string to stack
94 il.Emit(OpCodes.Ldstr, "Hello World!"); 94 il.Emit(OpCodes.Ldstr, "Hello World!");
95 95
96 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); 96 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
97 il.Emit(OpCodes.Call, typeof(Console).GetMethod 97 il.Emit(OpCodes.Call, typeof(Console).GetMethod
98 ("WriteLine", new Type[] { typeof(string) })); 98 ("WriteLine", new Type[] { typeof(string) }));
99 99
100 //il.EmitCall(OpCodes.Callvirt 100 //il.EmitCall(OpCodes.Callvirt
101 //il.Emit(OpCodes.Call, typeof(WorldAPI).GetMethod 101 //il.Emit(OpCodes.Call, typeof(WorldAPI).GetMethod
102 //("TestFunction")); 102 //("TestFunction"));
103 103
104 104
105 //il.ThrowException(typeof(NotSupportedException)); 105 //il.ThrowException(typeof(NotSupportedException));
106 106
107 107
108 /* 108 /*
109 * CATCH 109 * CATCH
110 */ 110 */
111 il.BeginCatchBlock(typeof(Exception)); 111 il.BeginCatchBlock(typeof(Exception));
112 112
113 // Push "Hello World!" string to stack 113 // Push "Hello World!" string to stack
114 il.Emit(OpCodes.Ldstr, "Something went wrong: "); 114 il.Emit(OpCodes.Ldstr, "Something went wrong: ");
115 115
116 //call void [mscorlib]System.Console::WriteLine(string) 116 //call void [mscorlib]System.Console::WriteLine(string)
117 il.Emit(OpCodes.Call, typeof(Console).GetMethod 117 il.Emit(OpCodes.Call, typeof(Console).GetMethod
118 ("Write", new Type[] { typeof(string) })); 118 ("Write", new Type[] { typeof(string) }));
119 119
120 //callvirt instance string [mscorlib]System.Exception::get_Message() 120 //callvirt instance string [mscorlib]System.Exception::get_Message()
121 il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod 121 il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod
122 ("get_Message")); 122 ("get_Message"));
123 123
124 //call void [mscorlib]System.Console::WriteLine(string) 124 //call void [mscorlib]System.Console::WriteLine(string)
125 il.Emit(OpCodes.Call, typeof(Console).GetMethod 125 il.Emit(OpCodes.Call, typeof(Console).GetMethod
126 ("WriteLine", new Type[] { typeof(string) })); 126 ("WriteLine", new Type[] { typeof(string) }));
127 127
128 /* 128 /*
129 * END TRY 129 * END TRY
130 */ 130 */
131 il.EndExceptionBlock(); 131 il.EndExceptionBlock();
132 132
133 133
134 // Push "Return from current method, with return value if present" to stack 134 // Push "Return from current method, with return value if present" to stack
135 il.Emit(OpCodes.Ret); 135 il.Emit(OpCodes.Ret);
136 136
137 137
138 } 138 }
139 } 139 }
140} 140}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs
index dc612ff..57bbf11 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs
@@ -1,51 +1,51 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.ScriptEngines.LSL 5namespace OpenSim.ScriptEngines.LSL
6{ 6{
7 public class LSL_CLRInterface 7 public class LSL_CLRInterface
8 { 8 {
9 public interface LSLScript 9 public interface LSLScript
10 { 10 {
11 //public virtual void Run(object arg) 11 //public virtual void Run(object arg)
12 //{ 12 //{
13 //} 13 //}
14 //void Run(object arg); 14 //void Run(object arg);
15 15
16 void event_state_entry(object arg); 16 void event_state_entry(object arg);
17 //void event_state_exit(); 17 //void event_state_exit();
18 void event_touch_start(object arg); 18 void event_touch_start(object arg);
19 //void event_touch(); 19 //void event_touch();
20 //void event_touch_end(); 20 //void event_touch_end();
21 //void event_collision_start(); 21 //void event_collision_start();
22 //void event_collision(); 22 //void event_collision();
23 //void event_collision_end(); 23 //void event_collision_end();
24 //void event_land_collision_start(); 24 //void event_land_collision_start();
25 //void event_land_collision(); 25 //void event_land_collision();
26 //void event_land_collision_end(); 26 //void event_land_collision_end();
27 //void event_timer(); 27 //void event_timer();
28 //void event_listen(); 28 //void event_listen();
29 //void event_on_rez(); 29 //void event_on_rez();
30 //void event_sensor(); 30 //void event_sensor();
31 //void event_no_sensor(); 31 //void event_no_sensor();
32 //void event_control(); 32 //void event_control();
33 //void event_money(); 33 //void event_money();
34 //void event_email(); 34 //void event_email();
35 //void event_at_target(); 35 //void event_at_target();
36 //void event_not_at_target(); 36 //void event_not_at_target();
37 //void event_at_rot_target(); 37 //void event_at_rot_target();
38 //void event_not_at_rot_target(); 38 //void event_not_at_rot_target();
39 //void event_run_time_permissions(); 39 //void event_run_time_permissions();
40 //void event_changed(); 40 //void event_changed();
41 //void event_attach(); 41 //void event_attach();
42 //void event_dataserver(); 42 //void event_dataserver();
43 //void event_link_message(); 43 //void event_link_message();
44 //void event_moving_start(); 44 //void event_moving_start();
45 //void event_moving_end(); 45 //void event_moving_end();
46 //void event_object_rez(); 46 //void event_object_rez();
47 //void event_remote_data(); 47 //void event_remote_data();
48 //void event_http_response(); 48 //void event_http_response();
49 } 49 }
50 } 50 }
51} 51}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs
index edeccdd..b45abe0 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs
@@ -1,485 +1,485 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5namespace OpenSim.ScriptEngines.LSL 5namespace OpenSim.ScriptEngines.LSL
6{ 6{
7 static class LSO_Enums 7 static class LSO_Enums
8 { 8 {
9 9
10 public enum Variable_Type_Codes 10 public enum Variable_Type_Codes
11 { 11 {
12 Void = 0, 12 Void = 0,
13 Integer = 1, 13 Integer = 1,
14 Float = 2, 14 Float = 2,
15 String = 3, 15 String = 3,
16 Key = 4, 16 Key = 4,
17 Vector = 5, 17 Vector = 5,
18 Rotation = 6, 18 Rotation = 6,
19 List = 7 19 List = 7
20 } 20 }
21 public enum Event_Mask_Values 21 public enum Event_Mask_Values
22 { 22 {
23 state_entry = 0, 23 state_entry = 0,
24 state_exit = 1, 24 state_exit = 1,
25 touch_start = 2, 25 touch_start = 2,
26 touch = 3, 26 touch = 3,
27 touch_end = 4, 27 touch_end = 4,
28 collision_start = 5, 28 collision_start = 5,
29 collision = 6, 29 collision = 6,
30 collision_end = 7, 30 collision_end = 7,
31 land_collision_start = 8, 31 land_collision_start = 8,
32 land_collision = 9, 32 land_collision = 9,
33 land_collision_end = 10, 33 land_collision_end = 10,
34 timer = 11, 34 timer = 11,
35 listen = 12, 35 listen = 12,
36 on_rez = 13, 36 on_rez = 13,
37 sensor = 14, 37 sensor = 14,
38 no_sensor = 15, 38 no_sensor = 15,
39 control = 16, 39 control = 16,
40 money = 17, 40 money = 17,
41 email = 18, 41 email = 18,
42 at_target = 19, 42 at_target = 19,
43 not_at_target = 20, 43 not_at_target = 20,
44 at_rot_target = 21, 44 at_rot_target = 21,
45 not_at_rot_target = 22, 45 not_at_rot_target = 22,
46 run_time_permissions = 23, 46 run_time_permissions = 23,
47 changed = 24, 47 changed = 24,
48 attach = 25, 48 attach = 25,
49 dataserver = 26, 49 dataserver = 26,
50 link_message = 27, 50 link_message = 27,
51 moving_start = 28, 51 moving_start = 28,
52 moving_end = 29, 52 moving_end = 29,
53 object_rez = 30, 53 object_rez = 30,
54 remote_data = 31, 54 remote_data = 31,
55 http_response = 32 55 http_response = 32
56 } 56 }
57 public enum Operation_Table 57 public enum Operation_Table
58 { 58 {
59 NOOP = 0x0, 59 NOOP = 0x0,
60 POP = 0x1, 60 POP = 0x1,
61 POPS = 0x2, 61 POPS = 0x2,
62 POPL = 0x3, 62 POPL = 0x3,
63 POPV = 0x4, 63 POPV = 0x4,
64 POPQ = 0x5, 64 POPQ = 0x5,
65 POPARG = 0x6, 65 POPARG = 0x6,
66 POPIP = 0x7, 66 POPIP = 0x7,
67 POPBP = 0x8, 67 POPBP = 0x8,
68 POPSP = 0x9, 68 POPSP = 0x9,
69 POPSLR = 0xa, 69 POPSLR = 0xa,
70 DUP = 0x20, 70 DUP = 0x20,
71 DUPS = 0x21, 71 DUPS = 0x21,
72 DUPL = 0x22, 72 DUPL = 0x22,
73 DUPV = 0x23, 73 DUPV = 0x23,
74 DUPQ = 0x24, 74 DUPQ = 0x24,
75 STORE = 0x30, 75 STORE = 0x30,
76 STORES = 0x31, 76 STORES = 0x31,
77 STOREL = 0x32, 77 STOREL = 0x32,
78 STOREV = 0x33, 78 STOREV = 0x33,
79 STOREQ = 0x34, 79 STOREQ = 0x34,
80 STOREG = 0x35, 80 STOREG = 0x35,
81 STOREGS = 0x36, 81 STOREGS = 0x36,
82 STOREGL = 0x37, 82 STOREGL = 0x37,
83 STOREGV = 0x38, 83 STOREGV = 0x38,
84 STOREGQ = 0x39, 84 STOREGQ = 0x39,
85 LOADP = 0x3a, 85 LOADP = 0x3a,
86 LOADSP = 0x3b, 86 LOADSP = 0x3b,
87 LOADLP = 0x3c, 87 LOADLP = 0x3c,
88 LOADVP = 0x3d, 88 LOADVP = 0x3d,
89 LOADQP = 0x3e, 89 LOADQP = 0x3e,
90 LOADGP = 0x3f, 90 LOADGP = 0x3f,
91 LOADGSP = 0x40, 91 LOADGSP = 0x40,
92 LOADGLP = 0x41, 92 LOADGLP = 0x41,
93 LOADGVP = 0x42, 93 LOADGVP = 0x42,
94 LOADGQP = 0x43, 94 LOADGQP = 0x43,
95 PUSH = 0x50, 95 PUSH = 0x50,
96 PUSHS = 0x51, 96 PUSHS = 0x51,
97 PUSHL = 0x52, 97 PUSHL = 0x52,
98 PUSHV = 0x53, 98 PUSHV = 0x53,
99 PUSHQ = 0x54, 99 PUSHQ = 0x54,
100 PUSHG = 0x55, 100 PUSHG = 0x55,
101 PUSHGS = 0x56, 101 PUSHGS = 0x56,
102 PUSHGL = 0x57, 102 PUSHGL = 0x57,
103 PUSHGV = 0x58, 103 PUSHGV = 0x58,
104 PUSHGQ = 0x59, 104 PUSHGQ = 0x59,
105 PUSHIP = 0x5a, 105 PUSHIP = 0x5a,
106 PUSHBP = 0x5b, 106 PUSHBP = 0x5b,
107 PUSHSP = 0x5c, 107 PUSHSP = 0x5c,
108 PUSHARGB = 0x5d, 108 PUSHARGB = 0x5d,
109 PUSHARGI = 0x5e, 109 PUSHARGI = 0x5e,
110 PUSHARGF = 0x5f, 110 PUSHARGF = 0x5f,
111 PUSHARGS = 0x60, 111 PUSHARGS = 0x60,
112 PUSHARGV = 0x61, 112 PUSHARGV = 0x61,
113 PUSHARGQ = 0x62, 113 PUSHARGQ = 0x62,
114 PUSHE = 0x63, 114 PUSHE = 0x63,
115 PUSHEV = 0x64, 115 PUSHEV = 0x64,
116 PUSHEQ = 0x65, 116 PUSHEQ = 0x65,
117 PUSHARGE = 0x66, 117 PUSHARGE = 0x66,
118 ADD = 0x70, 118 ADD = 0x70,
119 SUB = 0x71, 119 SUB = 0x71,
120 MUL = 0x72, 120 MUL = 0x72,
121 DIV = 0x73, 121 DIV = 0x73,
122 MOD = 0x74, 122 MOD = 0x74,
123 EQ = 0x75, 123 EQ = 0x75,
124 NEQ = 0x76, 124 NEQ = 0x76,
125 LEQ = 0x77, 125 LEQ = 0x77,
126 GEQ = 0x78, 126 GEQ = 0x78,
127 LESS = 0x79, 127 LESS = 0x79,
128 GREATER = 0x7a, 128 GREATER = 0x7a,
129 BITAND = 0x7b, 129 BITAND = 0x7b,
130 BITOR = 0x7c, 130 BITOR = 0x7c,
131 BITXOR = 0x7d, 131 BITXOR = 0x7d,
132 BOOLAND = 0x7e, 132 BOOLAND = 0x7e,
133 BOOLOR = 0x7f, 133 BOOLOR = 0x7f,
134 NEG = 0x80, 134 NEG = 0x80,
135 BITNOT = 0x81, 135 BITNOT = 0x81,
136 BOOLNOT = 0x82, 136 BOOLNOT = 0x82,
137 JUMP = 0x90, 137 JUMP = 0x90,
138 JUMPIF = 0x91, 138 JUMPIF = 0x91,
139 JUMPNIF = 0x92, 139 JUMPNIF = 0x92,
140 STATE = 0x93, 140 STATE = 0x93,
141 CALL = 0x94, 141 CALL = 0x94,
142 RETURN = 0x95, 142 RETURN = 0x95,
143 CAST = 0xa0, 143 CAST = 0xa0,
144 STACKTOS = 0xb0, 144 STACKTOS = 0xb0,
145 STACKTOL = 0xb1, 145 STACKTOL = 0xb1,
146 PRINT = 0xc0, 146 PRINT = 0xc0,
147 CALLLIB = 0xd0, 147 CALLLIB = 0xd0,
148 CALLLIB_TWO_BYTE = 0xd1, 148 CALLLIB_TWO_BYTE = 0xd1,
149 SHL = 0xe0, 149 SHL = 0xe0,
150 SHR = 0xe1 150 SHR = 0xe1
151 } 151 }
152 public enum BuiltIn_Functions 152 public enum BuiltIn_Functions
153 { 153 {
154 llSin = 0, 154 llSin = 0,
155 llCos = 1, 155 llCos = 1,
156 llTan = 2, 156 llTan = 2,
157 llAtan2 = 3, 157 llAtan2 = 3,
158 llSqrt = 4, 158 llSqrt = 4,
159 llPow = 5, 159 llPow = 5,
160 llAbs = 6, 160 llAbs = 6,
161 llFabs = 7, 161 llFabs = 7,
162 llFrand = 8, 162 llFrand = 8,
163 llFloor = 9, 163 llFloor = 9,
164 llCeil = 10, 164 llCeil = 10,
165 llRound = 11, 165 llRound = 11,
166 llVecMag = 12, 166 llVecMag = 12,
167 llVecNorm = 13, 167 llVecNorm = 13,
168 llVecDist = 14, 168 llVecDist = 14,
169 llRot2Euler = 15, 169 llRot2Euler = 15,
170 llEuler2Rot = 16, 170 llEuler2Rot = 16,
171 llAxes2Rot = 17, 171 llAxes2Rot = 17,
172 llRot2Fwd = 18, 172 llRot2Fwd = 18,
173 llRot2Left = 19, 173 llRot2Left = 19,
174 llRot2Up = 20, 174 llRot2Up = 20,
175 llRotBetween = 21, 175 llRotBetween = 21,
176 llWhisper = 22, 176 llWhisper = 22,
177 llSay = 23, 177 llSay = 23,
178 llShout = 24, 178 llShout = 24,
179 llListen = 25, 179 llListen = 25,
180 llListenControl = 26, 180 llListenControl = 26,
181 llListenRemove = 27, 181 llListenRemove = 27,
182 llSensor = 28, 182 llSensor = 28,
183 llSensorRepeat = 29, 183 llSensorRepeat = 29,
184 llSensorRemove = 30, 184 llSensorRemove = 30,
185 llDetectedName = 31, 185 llDetectedName = 31,
186 llDetectedKey = 32, 186 llDetectedKey = 32,
187 llDetectedOwner = 33, 187 llDetectedOwner = 33,
188 llDetectedType = 34, 188 llDetectedType = 34,
189 llDetectedPos = 35, 189 llDetectedPos = 35,
190 llDetectedVel = 36, 190 llDetectedVel = 36,
191 llDetectedGrab = 37, 191 llDetectedGrab = 37,
192 llDetectedRot = 38, 192 llDetectedRot = 38,
193 llDetectedGroup = 39, 193 llDetectedGroup = 39,
194 llDetectedLinkNumber = 40, 194 llDetectedLinkNumber = 40,
195 llDie = 41, 195 llDie = 41,
196 llGround = 42, 196 llGround = 42,
197 llCloud = 43, 197 llCloud = 43,
198 llWind = 44, 198 llWind = 44,
199 llSetStatus = 45, 199 llSetStatus = 45,
200 llGetStatus = 46, 200 llGetStatus = 46,
201 llSetScale = 47, 201 llSetScale = 47,
202 llGetScale = 48, 202 llGetScale = 48,
203 llSetColor = 49, 203 llSetColor = 49,
204 llGetAlpha = 50, 204 llGetAlpha = 50,
205 llSetAlpha = 51, 205 llSetAlpha = 51,
206 llGetColor = 52, 206 llGetColor = 52,
207 llSetTexture = 53, 207 llSetTexture = 53,
208 llScaleTexture = 54, 208 llScaleTexture = 54,
209 llOffsetTexture = 55, 209 llOffsetTexture = 55,
210 llRotateTexture = 56, 210 llRotateTexture = 56,
211 llGetTexture = 57, 211 llGetTexture = 57,
212 llSetPos = 58, 212 llSetPos = 58,
213 llGetPos = 59, 213 llGetPos = 59,
214 llGetLocalPos = 60, 214 llGetLocalPos = 60,
215 llSetRot = 61, 215 llSetRot = 61,
216 llGetRot = 62, 216 llGetRot = 62,
217 llGetLocalRot = 63, 217 llGetLocalRot = 63,
218 llSetForce = 64, 218 llSetForce = 64,
219 llGetForce = 65, 219 llGetForce = 65,
220 llTarget = 66, 220 llTarget = 66,
221 llTargetRemove = 67, 221 llTargetRemove = 67,
222 llRotTarget = 68, 222 llRotTarget = 68,
223 llRotTargetRemove = 69, 223 llRotTargetRemove = 69,
224 llMoveToTarget = 70, 224 llMoveToTarget = 70,
225 llStopMoveToTarget = 71, 225 llStopMoveToTarget = 71,
226 llApplyImpulse = 72, 226 llApplyImpulse = 72,
227 llApplyRotationalImpulse = 73, 227 llApplyRotationalImpulse = 73,
228 llSetTorque = 74, 228 llSetTorque = 74,
229 llGetTorque = 75, 229 llGetTorque = 75,
230 llSetForceAndTorque = 76, 230 llSetForceAndTorque = 76,
231 llGetVel = 77, 231 llGetVel = 77,
232 llGetAccel = 78, 232 llGetAccel = 78,
233 llGetOmega = 79, 233 llGetOmega = 79,
234 llGetTimeOfDay = 80, 234 llGetTimeOfDay = 80,
235 llGetWallclock = 81, 235 llGetWallclock = 81,
236 llGetTime = 82, 236 llGetTime = 82,
237 llResetTime = 83, 237 llResetTime = 83,
238 llGetAndResetTime = 84, 238 llGetAndResetTime = 84,
239 llSound = 85, 239 llSound = 85,
240 llPlaySound = 86, 240 llPlaySound = 86,
241 llLoopSound = 87, 241 llLoopSound = 87,
242 llLoopSoundMaster = 88, 242 llLoopSoundMaster = 88,
243 llLoopSoundSlave = 89, 243 llLoopSoundSlave = 89,
244 llPlaySoundSlave = 90, 244 llPlaySoundSlave = 90,
245 llTriggerSound = 91, 245 llTriggerSound = 91,
246 llStopSound = 92, 246 llStopSound = 92,
247 llPreloadSound = 93, 247 llPreloadSound = 93,
248 llGetSubString = 94, 248 llGetSubString = 94,
249 llDeleteSubString = 95, 249 llDeleteSubString = 95,
250 llInsertString = 96, 250 llInsertString = 96,
251 llToUpper = 97, 251 llToUpper = 97,
252 llToLower = 98, 252 llToLower = 98,
253 llGiveMoney = 99, 253 llGiveMoney = 99,
254 llMakeExplosion = 100, 254 llMakeExplosion = 100,
255 llMakeFountain = 101, 255 llMakeFountain = 101,
256 llMakeSmoke = 102, 256 llMakeSmoke = 102,
257 llMakeFire = 103, 257 llMakeFire = 103,
258 llRezObject = 104, 258 llRezObject = 104,
259 llLookAt = 105, 259 llLookAt = 105,
260 llStopLookAt = 106, 260 llStopLookAt = 106,
261 llSetTimerEvent = 107, 261 llSetTimerEvent = 107,
262 llSleep = 108, 262 llSleep = 108,
263 llGetMass = 109, 263 llGetMass = 109,
264 llCollisionFilter = 110, 264 llCollisionFilter = 110,
265 llTakeControls = 111, 265 llTakeControls = 111,
266 llReleaseControls = 112, 266 llReleaseControls = 112,
267 llAttachToAvatar = 113, 267 llAttachToAvatar = 113,
268 llDetachFromAvatar = 114, 268 llDetachFromAvatar = 114,
269 llTakeCamera = 115, 269 llTakeCamera = 115,
270 llReleaseCamera = 116, 270 llReleaseCamera = 116,
271 llGetOwner = 117, 271 llGetOwner = 117,
272 llInstantMessage = 118, 272 llInstantMessage = 118,
273 llEmail = 119, 273 llEmail = 119,
274 llGetNextEmail = 120, 274 llGetNextEmail = 120,
275 llGetKey = 121, 275 llGetKey = 121,
276 llSetBuoyancy = 122, 276 llSetBuoyancy = 122,
277 llSetHoverHeight = 123, 277 llSetHoverHeight = 123,
278 llStopHover = 124, 278 llStopHover = 124,
279 llMinEventDelay = 125, 279 llMinEventDelay = 125,
280 llSoundPreload = 126, 280 llSoundPreload = 126,
281 llRotLookAt = 127, 281 llRotLookAt = 127,
282 llStringLength = 128, 282 llStringLength = 128,
283 llStartAnimation = 129, 283 llStartAnimation = 129,
284 llStopAnimation = 130, 284 llStopAnimation = 130,
285 llPointAt = 131, 285 llPointAt = 131,
286 llStopPointAt = 132, 286 llStopPointAt = 132,
287 llTargetOmega = 133, 287 llTargetOmega = 133,
288 llGetStartParameter = 134, 288 llGetStartParameter = 134,
289 llGodLikeRezObject = 135, 289 llGodLikeRezObject = 135,
290 llRequestPermissions = 136, 290 llRequestPermissions = 136,
291 llGetPermissionsKey = 137, 291 llGetPermissionsKey = 137,
292 llGetPermissions = 138, 292 llGetPermissions = 138,
293 llGetLinkNumber = 139, 293 llGetLinkNumber = 139,
294 llSetLinkColor = 140, 294 llSetLinkColor = 140,
295 llCreateLink = 141, 295 llCreateLink = 141,
296 llBreakLink = 142, 296 llBreakLink = 142,
297 llBreakAllLinks = 143, 297 llBreakAllLinks = 143,
298 llGetLinkKey = 144, 298 llGetLinkKey = 144,
299 llGetLinkName = 145, 299 llGetLinkName = 145,
300 llGetInventoryNumber = 146, 300 llGetInventoryNumber = 146,
301 llGetInventoryName = 147, 301 llGetInventoryName = 147,
302 llSetScriptState = 148, 302 llSetScriptState = 148,
303 llGetEnergy = 149, 303 llGetEnergy = 149,
304 llGiveInventory = 150, 304 llGiveInventory = 150,
305 llRemoveInventory = 151, 305 llRemoveInventory = 151,
306 llSetText = 152, 306 llSetText = 152,
307 llWater = 153, 307 llWater = 153,
308 llPassTouches = 154, 308 llPassTouches = 154,
309 llRequestAgentData = 155, 309 llRequestAgentData = 155,
310 llRequestInventoryData = 156, 310 llRequestInventoryData = 156,
311 llSetDamage = 157, 311 llSetDamage = 157,
312 llTeleportAgentHome = 158, 312 llTeleportAgentHome = 158,
313 llModifyLand = 159, 313 llModifyLand = 159,
314 llCollisionSound = 160, 314 llCollisionSound = 160,
315 llCollisionSprite = 161, 315 llCollisionSprite = 161,
316 llGetAnimation = 162, 316 llGetAnimation = 162,
317 llResetScript = 163, 317 llResetScript = 163,
318 llMessageLinked = 164, 318 llMessageLinked = 164,
319 llPushObject = 165, 319 llPushObject = 165,
320 llPassCollisions = 166, 320 llPassCollisions = 166,
321 llGetScriptName = 167, 321 llGetScriptName = 167,
322 llGetNumberOfSides = 168, 322 llGetNumberOfSides = 168,
323 llAxisAngle2Rot = 169, 323 llAxisAngle2Rot = 169,
324 llRot2Axis = 170, 324 llRot2Axis = 170,
325 llRot2Angle = 171, 325 llRot2Angle = 171,
326 llAcos = 172, 326 llAcos = 172,
327 llAsin = 173, 327 llAsin = 173,
328 llAngleBetween = 174, 328 llAngleBetween = 174,
329 llGetInventoryKey = 175, 329 llGetInventoryKey = 175,
330 llAllowInventoryDrop = 176, 330 llAllowInventoryDrop = 176,
331 llGetSunDirection = 177, 331 llGetSunDirection = 177,
332 llGetTextureOffset = 178, 332 llGetTextureOffset = 178,
333 llGetTextureScale = 179, 333 llGetTextureScale = 179,
334 llGetTextureRot = 180, 334 llGetTextureRot = 180,
335 llSubStringIndex = 181, 335 llSubStringIndex = 181,
336 llGetOwnerKey = 182, 336 llGetOwnerKey = 182,
337 llGetCenterOfMass = 183, 337 llGetCenterOfMass = 183,
338 llListSort = 184, 338 llListSort = 184,
339 llGetListLength = 185, 339 llGetListLength = 185,
340 llList2Integer = 186, 340 llList2Integer = 186,
341 llList2Float = 187, 341 llList2Float = 187,
342 llList2String = 188, 342 llList2String = 188,
343 llList2Key = 189, 343 llList2Key = 189,
344 llList2Vector = 190, 344 llList2Vector = 190,
345 llList2Rot = 191, 345 llList2Rot = 191,
346 llList2List = 192, 346 llList2List = 192,
347 llDeleteSubList = 193, 347 llDeleteSubList = 193,
348 llGetListEntryType = 194, 348 llGetListEntryType = 194,
349 llList2CSV = 195, 349 llList2CSV = 195,
350 llCSV2List = 196, 350 llCSV2List = 196,
351 llListRandomize = 197, 351 llListRandomize = 197,
352 llList2ListStrided = 198, 352 llList2ListStrided = 198,
353 llGetRegionCorner = 199, 353 llGetRegionCorner = 199,
354 llListInsertList = 200, 354 llListInsertList = 200,
355 llListFindList = 201, 355 llListFindList = 201,
356 llGetObjectName = 202, 356 llGetObjectName = 202,
357 llSetObjectName = 203, 357 llSetObjectName = 203,
358 llGetDate = 204, 358 llGetDate = 204,
359 llEdgeOfWorld = 205, 359 llEdgeOfWorld = 205,
360 llGetAgentInfo = 206, 360 llGetAgentInfo = 206,
361 llAdjustSoundVolume = 207, 361 llAdjustSoundVolume = 207,
362 llSetSoundQueueing = 208, 362 llSetSoundQueueing = 208,
363 llSetSoundRadius = 209, 363 llSetSoundRadius = 209,
364 llKey2Name = 210, 364 llKey2Name = 210,
365 llSetTextureAnim = 211, 365 llSetTextureAnim = 211,
366 llTriggerSoundLimited = 212, 366 llTriggerSoundLimited = 212,
367 llEjectFromLand = 213, 367 llEjectFromLand = 213,
368 llParseString2List = 214, 368 llParseString2List = 214,
369 llOverMyLand = 215, 369 llOverMyLand = 215,
370 llGetLandOwnerAt = 216, 370 llGetLandOwnerAt = 216,
371 llGetNotecardLine = 217, 371 llGetNotecardLine = 217,
372 llGetAgentSize = 218, 372 llGetAgentSize = 218,
373 llSameGroup = 219, 373 llSameGroup = 219,
374 llUnSit = 220, 374 llUnSit = 220,
375 llGroundSlope = 221, 375 llGroundSlope = 221,
376 llGroundNormal = 222, 376 llGroundNormal = 222,
377 llGroundContour = 223, 377 llGroundContour = 223,
378 llGetAttached = 224, 378 llGetAttached = 224,
379 llGetFreeMemory = 225, 379 llGetFreeMemory = 225,
380 llGetRegionName = 226, 380 llGetRegionName = 226,
381 llGetRegionTimeDilation = 227, 381 llGetRegionTimeDilation = 227,
382 llGetRegionFPS = 228, 382 llGetRegionFPS = 228,
383 llParticleSystem = 229, 383 llParticleSystem = 229,
384 llGroundRepel = 230, 384 llGroundRepel = 230,
385 llGiveInventoryList = 231, 385 llGiveInventoryList = 231,
386 llSetVehicleType = 232, 386 llSetVehicleType = 232,
387 llSetVehicleFloatParam = 233, 387 llSetVehicleFloatParam = 233,
388 llSetVehicleVectorParam = 234, 388 llSetVehicleVectorParam = 234,
389 llSetVehicleRotationParam = 235, 389 llSetVehicleRotationParam = 235,
390 llSetVehicleFlags = 236, 390 llSetVehicleFlags = 236,
391 llRemoveVehicleFlags = 237, 391 llRemoveVehicleFlags = 237,
392 llSitTarget = 238, 392 llSitTarget = 238,
393 llAvatarOnSitTarget = 239, 393 llAvatarOnSitTarget = 239,
394 llAddToLandPassList = 240, 394 llAddToLandPassList = 240,
395 llSetTouchText = 241, 395 llSetTouchText = 241,
396 llSetSitText = 242, 396 llSetSitText = 242,
397 llSetCameraEyeOffset = 243, 397 llSetCameraEyeOffset = 243,
398 llSetCameraAtOffset = 244, 398 llSetCameraAtOffset = 244,
399 llDumpList2String = 245, 399 llDumpList2String = 245,
400 llScriptDanger = 246, 400 llScriptDanger = 246,
401 llDialog = 247, 401 llDialog = 247,
402 llVolumeDetect = 248, 402 llVolumeDetect = 248,
403 llResetOtherScript = 249, 403 llResetOtherScript = 249,
404 llGetScriptState = 250, 404 llGetScriptState = 250,
405 llRemoteLoadScript = 251, 405 llRemoteLoadScript = 251,
406 llSetRemoteScriptAccessPin = 252, 406 llSetRemoteScriptAccessPin = 252,
407 llRemoteLoadScriptPin = 253, 407 llRemoteLoadScriptPin = 253,
408 llOpenRemoteDataChannel = 254, 408 llOpenRemoteDataChannel = 254,
409 llSendRemoteData = 255, 409 llSendRemoteData = 255,
410 llRemoteDataReply = 256, 410 llRemoteDataReply = 256,
411 llCloseRemoteDataChannel = 257, 411 llCloseRemoteDataChannel = 257,
412 llMD5String = 258, 412 llMD5String = 258,
413 llSetPrimitiveParams = 259, 413 llSetPrimitiveParams = 259,
414 llStringToBase64 = 260, 414 llStringToBase64 = 260,
415 llBase64ToString = 261, 415 llBase64ToString = 261,
416 llXorBase64Strings = 262, 416 llXorBase64Strings = 262,
417 llRemoteDataSetRegion = 263, 417 llRemoteDataSetRegion = 263,
418 llLog10 = 264, 418 llLog10 = 264,
419 llLog = 265, 419 llLog = 265,
420 llGetAnimationList = 266, 420 llGetAnimationList = 266,
421 llSetParcelMusicURL = 267, 421 llSetParcelMusicURL = 267,
422 llGetRootPosition = 268, 422 llGetRootPosition = 268,
423 llGetRootRotation = 269, 423 llGetRootRotation = 269,
424 llGetObjectDesc = 270, 424 llGetObjectDesc = 270,
425 llSetObjectDesc = 271, 425 llSetObjectDesc = 271,
426 llGetCreator = 272, 426 llGetCreator = 272,
427 llGetTimestamp = 273, 427 llGetTimestamp = 273,
428 llSetLinkAlpha = 274, 428 llSetLinkAlpha = 274,
429 llGetNumberOfPrims = 275, 429 llGetNumberOfPrims = 275,
430 llGetNumberOfNotecardLines = 276, 430 llGetNumberOfNotecardLines = 276,
431 llGetBoundingBox = 277, 431 llGetBoundingBox = 277,
432 llGetGeometricCenter = 278, 432 llGetGeometricCenter = 278,
433 llGetPrimitiveParams = 279, 433 llGetPrimitiveParams = 279,
434 llIntegerToBase64 = 280, 434 llIntegerToBase64 = 280,
435 llBase64ToInteger = 281, 435 llBase64ToInteger = 281,
436 llGetGMTclock = 282, 436 llGetGMTclock = 282,
437 llGetSimulatorHostname = 283, 437 llGetSimulatorHostname = 283,
438 llSetLocalRot = 284, 438 llSetLocalRot = 284,
439 llParseStringKeepNulls = 285, 439 llParseStringKeepNulls = 285,
440 llRezAtRoot = 286, 440 llRezAtRoot = 286,
441 llGetObjectPermMask = 287, 441 llGetObjectPermMask = 287,
442 llSetObjectPermMask = 288, 442 llSetObjectPermMask = 288,
443 llGetInventoryPermMask = 289, 443 llGetInventoryPermMask = 289,
444 llSetInventoryPermMask = 290, 444 llSetInventoryPermMask = 290,
445 llGetInventoryCreator = 291, 445 llGetInventoryCreator = 291,
446 llOwnerSay = 292, 446 llOwnerSay = 292,
447 llRequestSimulatorData = 293, 447 llRequestSimulatorData = 293,
448 llForceMouselook = 294, 448 llForceMouselook = 294,
449 llGetObjectMass = 295, 449 llGetObjectMass = 295,
450 llListReplaceList = 296, 450 llListReplaceList = 296,
451 llLoadURL = 297, 451 llLoadURL = 297,
452 llParcelMediaCommandList = 298, 452 llParcelMediaCommandList = 298,
453 llParcelMediaQuery = 299, 453 llParcelMediaQuery = 299,
454 llModPow = 300, 454 llModPow = 300,
455 llGetInventoryType = 301, 455 llGetInventoryType = 301,
456 llSetPayPrice = 302, 456 llSetPayPrice = 302,
457 llGetCameraPos = 303, 457 llGetCameraPos = 303,
458 llGetCameraRot = 304, 458 llGetCameraRot = 304,
459 llSetPrimURL = 305, 459 llSetPrimURL = 305,
460 llRefreshPrimURL = 306, 460 llRefreshPrimURL = 306,
461 llEscapeURL = 307, 461 llEscapeURL = 307,
462 llUnescapeURL = 308, 462 llUnescapeURL = 308,
463 llMapDestination = 309, 463 llMapDestination = 309,
464 llAddToLandBanList = 310, 464 llAddToLandBanList = 310,
465 llRemoveFromLandPassList = 311, 465 llRemoveFromLandPassList = 311,
466 llRemoveFromLandBanList = 312, 466 llRemoveFromLandBanList = 312,
467 llSetCameraParams = 313, 467 llSetCameraParams = 313,
468 llClearCameraParams = 314, 468 llClearCameraParams = 314,
469 llListStatistics = 315, 469 llListStatistics = 315,
470 llGetUnixTime = 316, 470 llGetUnixTime = 316,
471 llGetParcelFlags = 317, 471 llGetParcelFlags = 317,
472 llGetRegionFlags = 318, 472 llGetRegionFlags = 318,
473 llXorBase64StringsCorrect = 319, 473 llXorBase64StringsCorrect = 319,
474 llHTTPRequest = 320, 474 llHTTPRequest = 320,
475 llResetLandBanList = 321, 475 llResetLandBanList = 321,
476 llResetLandPassList = 322, 476 llResetLandPassList = 322,
477 llGetParcelPrimCount = 323, 477 llGetParcelPrimCount = 323,
478 llGetParcelPrimOwners = 324, 478 llGetParcelPrimOwners = 324,
479 llGetObjectPrimCount = 325, 479 llGetObjectPrimCount = 325,
480 llGetParcelMaxPrims = 326, 480 llGetParcelMaxPrims = 326,
481 llGetParcelDetails = 327 481 llGetParcelDetails = 327
482 } 482 }
483 483
484 } 484 }
485} 485}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs
index 2da1189..ebe4465 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs
@@ -1,608 +1,608 @@
1 using System; 1 using System;
2 using System.Collections.Generic; 2 using System.Collections.Generic;
3 using System.Text; 3 using System.Text;
4 using System.IO; 4 using System.IO;
5 using System.Reflection; 5 using System.Reflection;
6 using System.Reflection.Emit; 6 using System.Reflection.Emit;
7using OpenSim.Region.Scripting; 7using OpenSim.Region.Scripting;
8 8
9 namespace OpenSim.ScriptEngines.LSL 9 namespace OpenSim.ScriptEngines.LSL
10 { 10 {
11 class LSO_Parser 11 class LSO_Parser
12 { 12 {
13 private bool Debug = true; 13 private bool Debug = true;
14 private FileStream fs; 14 private FileStream fs;
15 private BinaryReader br; 15 private BinaryReader br;
16 private LSO_Struct.Header myHeader; 16 private LSO_Struct.Header myHeader;
17 17
18 private TypeBuilder typeBuilder; 18 private TypeBuilder typeBuilder;
19 private ScriptInfo WorldAPI; 19 private ScriptInfo WorldAPI;
20 20
21 /// <summary> 21 /// <summary>
22 /// Parse LSO file. 22 /// Parse LSO file.
23 /// Reads LSO ByteCode into memory structures. 23 /// Reads LSO ByteCode into memory structures.
24 /// TODO: What else does it do? 24 /// TODO: What else does it do?
25 /// </summary> 25 /// </summary>
26 /// <param name="FileName">FileName of LSO ByteCode file</param> 26 /// <param name="FileName">FileName of LSO ByteCode file</param>
27 public void ParseFile(string FileName, ScriptInfo _WorldAPI, ref TypeBuilder _typeBuilder) 27 public void ParseFile(string FileName, ScriptInfo _WorldAPI, ref TypeBuilder _typeBuilder)
28 { 28 {
29 typeBuilder = _typeBuilder; 29 typeBuilder = _typeBuilder;
30 WorldAPI = _WorldAPI; 30 WorldAPI = _WorldAPI;
31 // Open 31 // Open
32 SendToDebug("Opening filename: " + FileName); 32 SendToDebug("Opening filename: " + FileName);
33 fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); 33 fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
34 br = new BinaryReader(fs, Encoding.BigEndianUnicode); 34 br = new BinaryReader(fs, Encoding.BigEndianUnicode);
35 35
36 36
37 // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. 37 // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack.
38 38
39 39
40 // HEADER BLOCK 40 // HEADER BLOCK
41 SendToDebug("Reading HEADER BLOCK at: 0"); 41 SendToDebug("Reading HEADER BLOCK at: 0");
42 fs.Seek(0, SeekOrigin.Begin); 42 fs.Seek(0, SeekOrigin.Begin);
43 myHeader = new LSO_Struct.Header(); 43 myHeader = new LSO_Struct.Header();
44 myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); 44 myHeader.TM = BitConverter.ToUInt32(br_read(4), 0);
45 myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); 45 myHeader.IP = BitConverter.ToUInt32(br_read(4), 0);
46 myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); 46 myHeader.VN = BitConverter.ToUInt32(br_read(4), 0);
47 myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); 47 myHeader.BP = BitConverter.ToUInt32(br_read(4), 0);
48 myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); 48 myHeader.SP = BitConverter.ToUInt32(br_read(4), 0);
49 myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); 49 myHeader.HR = BitConverter.ToUInt32(br_read(4), 0);
50 myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); 50 myHeader.HP = BitConverter.ToUInt32(br_read(4), 0);
51 myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); 51 myHeader.CS = BitConverter.ToUInt32(br_read(4), 0);
52 myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); 52 myHeader.NS = BitConverter.ToUInt32(br_read(4), 0);
53 myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); 53 myHeader.CE = BitConverter.ToUInt32(br_read(4), 0);
54 myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); 54 myHeader.IE = BitConverter.ToUInt32(br_read(4), 0);
55 myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); 55 myHeader.ER = BitConverter.ToUInt32(br_read(4), 0);
56 myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); 56 myHeader.FR = BitConverter.ToUInt32(br_read(4), 0);
57 myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); 57 myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0);
58 myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); 58 myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0);
59 myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); 59 myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0);
60 myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); 60 myHeader.PR = BitConverter.ToUInt32(br_read(4), 0);
61 myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); 61 myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0);
62 myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); 62 myHeader.SR = BitConverter.ToUInt32(br_read(4), 0);
63 myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); 63 myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0);
64 myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); 64 myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0);
65 myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); 65 myHeader.NER = BitConverter.ToUInt64(br_read(8), 0);
66 66
67 // Print Header Block to debug 67 // Print Header Block to debug
68 SendToDebug("TM - Top of memory (size): " + myHeader.TM); 68 SendToDebug("TM - Top of memory (size): " + myHeader.TM);
69 SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); 69 SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP);
70 SendToDebug("VN - Version number: " + myHeader.VN); 70 SendToDebug("VN - Version number: " + myHeader.VN);
71 SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); 71 SendToDebug("BP - Local Frame Pointer: " + myHeader.BP);
72 SendToDebug("SP - Stack Pointer: " + myHeader.SP); 72 SendToDebug("SP - Stack Pointer: " + myHeader.SP);
73 SendToDebug("HR - Heap Register: " + myHeader.HR); 73 SendToDebug("HR - Heap Register: " + myHeader.HR);
74 SendToDebug("HP - Heap Pointer: " + myHeader.HP); 74 SendToDebug("HP - Heap Pointer: " + myHeader.HP);
75 SendToDebug("CS - Current State: " + myHeader.CS); 75 SendToDebug("CS - Current State: " + myHeader.CS);
76 SendToDebug("NS - Next State: " + myHeader.NS); 76 SendToDebug("NS - Next State: " + myHeader.NS);
77 SendToDebug("CE - Current Events: " + myHeader.CE); 77 SendToDebug("CE - Current Events: " + myHeader.CE);
78 SendToDebug("IE - In Event: " + myHeader.IE); 78 SendToDebug("IE - In Event: " + myHeader.IE);
79 SendToDebug("ER - Event Register: " + myHeader.ER); 79 SendToDebug("ER - Event Register: " + myHeader.ER);
80 SendToDebug("FR - Fault Register: " + myHeader.FR); 80 SendToDebug("FR - Fault Register: " + myHeader.FR);
81 SendToDebug("SLR - Sleep Register: " + myHeader.SLR); 81 SendToDebug("SLR - Sleep Register: " + myHeader.SLR);
82 SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); 82 SendToDebug("GVR - Global Variable Register: " + myHeader.GVR);
83 SendToDebug("GFR - Global Function Register: " + myHeader.GFR); 83 SendToDebug("GFR - Global Function Register: " + myHeader.GFR);
84 SendToDebug("PR - Parameter Register: " + myHeader.PR); 84 SendToDebug("PR - Parameter Register: " + myHeader.PR);
85 SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); 85 SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR);
86 SendToDebug("SR - State Register: " + myHeader.SR); 86 SendToDebug("SR - State Register: " + myHeader.SR);
87 SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); 87 SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE);
88 SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); 88 SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE);
89 SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); 89 SendToDebug("NER - 64-bit Event Register: " + myHeader.NER);
90 SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); 90 SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position);
91 91
92 // STATIC BLOCK 92 // STATIC BLOCK
93 SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); 93 SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR);
94 fs.Seek(myHeader.GVR, SeekOrigin.Begin); 94 fs.Seek(myHeader.GVR, SeekOrigin.Begin);
95 int StaticBlockCount = 0; 95 int StaticBlockCount = 0;
96 // Read function blocks until we hit GFR 96 // Read function blocks until we hit GFR
97 while (fs.Position < myHeader.GFR) 97 while (fs.Position < myHeader.GFR)
98 { 98 {
99 StaticBlockCount++; 99 StaticBlockCount++;
100 SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position); 100 SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position);
101 //fs.Seek(myHeader.GVR, SeekOrigin.Begin); 101 //fs.Seek(myHeader.GVR, SeekOrigin.Begin);
102 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); 102 LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock();
103 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); 103 myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0);
104 myStaticBlock.ObjectType = br_read(1)[0]; 104 myStaticBlock.ObjectType = br_read(1)[0];
105 SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); 105 SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString());
106 myStaticBlock.Unknown = br_read(1)[0]; 106 myStaticBlock.Unknown = br_read(1)[0];
107 // Size of datatype varies 107 // Size of datatype varies
108 if (myStaticBlock.ObjectType != 0) 108 if (myStaticBlock.ObjectType != 0)
109 myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); 109 myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType));
110 } 110 }
111 SendToDebug("Number of Static Blocks read: " + StaticBlockCount); 111 SendToDebug("Number of Static Blocks read: " + StaticBlockCount);
112 112
113 113
114 // FUNCTION BLOCK 114 // FUNCTION BLOCK
115 // Always right after STATIC BLOCK 115 // Always right after STATIC BLOCK
116 LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); 116 LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock();
117 if (myHeader.GFR == myHeader.SR) 117 if (myHeader.GFR == myHeader.SR)
118 { 118 {
119 // If GFR and SR are at same position then there is no fuction block 119 // If GFR and SR are at same position then there is no fuction block
120 SendToDebug("No FUNCTION BLOCK found"); 120 SendToDebug("No FUNCTION BLOCK found");
121 } else { 121 } else {
122 SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); 122 SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR);
123 fs.Seek(myHeader.GFR, SeekOrigin.Begin); 123 fs.Seek(myHeader.GFR, SeekOrigin.Begin);
124 myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); 124 myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0);
125 SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); 125 SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount);
126 if (myFunctionBlock.FunctionCount > 0) 126 if (myFunctionBlock.FunctionCount > 0)
127 { 127 {
128 myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; 128 myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount];
129 for (int i = 0; i < myFunctionBlock.FunctionCount; i++) 129 for (int i = 0; i < myFunctionBlock.FunctionCount; i++)
130 { 130 {
131 SendToDebug("Reading function " + i + " at: " + fs.Position); 131 SendToDebug("Reading function " + i + " at: " + fs.Position);
132 // TODO: ADD TO FUNCTION LIST (How do we identify it later?) 132 // TODO: ADD TO FUNCTION LIST (How do we identify it later?)
133 // Note! Absolute position 133 // Note! Absolute position
134 myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; 134 myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR;
135 SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); 135 SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]);
136 } 136 }
137 } 137 }
138 } 138 }
139 139
140 140
141 // STATE FRAME BLOCK 141 // STATE FRAME BLOCK
142 // Always right after FUNCTION BLOCK 142 // Always right after FUNCTION BLOCK
143 SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); 143 SendToDebug("Reading STATE BLOCK at: " + myHeader.SR);
144 fs.Seek(myHeader.SR, SeekOrigin.Begin); 144 fs.Seek(myHeader.SR, SeekOrigin.Begin);
145 LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); 145 LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock();
146 myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); 146 myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0);
147 if (myStateFrameBlock.StateCount > 0) 147 if (myStateFrameBlock.StateCount > 0)
148 { 148 {
149 // Initialize array 149 // Initialize array
150 myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; 150 myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount];
151 for (int i = 0; i < myStateFrameBlock.StateCount; i++) 151 for (int i = 0; i < myStateFrameBlock.StateCount; i++)
152 { 152 {
153 SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position); 153 SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position);
154 // Position is relative to state frame 154 // Position is relative to state frame
155 myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); 155 myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0);
156 myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); 156 myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8));
157 SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); 157 SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location);
158 SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); 158 SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count);
159 159
160 //// Read STATE BLOCK 160 //// Read STATE BLOCK
161 //long CurPos = fs.Position; 161 //long CurPos = fs.Position;
162 //fs.Seek(CurPos, SeekOrigin.Begin); 162 //fs.Seek(CurPos, SeekOrigin.Begin);
163 163
164 } 164 }
165 } 165 }
166 166
167 167
168 // STATE BLOCK 168 // STATE BLOCK
169 // For each StateFrameBlock there is one StateBlock with multiple event handlers 169 // For each StateFrameBlock there is one StateBlock with multiple event handlers
170 170
171 if (myStateFrameBlock.StateCount > 0) 171 if (myStateFrameBlock.StateCount > 0)
172 { 172 {
173 // Go through all State Frame Pointers found 173 // Go through all State Frame Pointers found
174 for (int i = 0; i < myStateFrameBlock.StateCount; i++) 174 for (int i = 0; i < myStateFrameBlock.StateCount; i++)
175 { 175 {
176 176
177 fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); 177 fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin);
178 SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); 178 SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position);
179 179
180 // READ: STATE BLOCK HEADER 180 // READ: STATE BLOCK HEADER
181 myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); 181 myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock();
182 myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note 182 myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note
183 myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); 183 myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0);
184 myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; 184 myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0];
185 myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note 185 myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note
186 SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); 186 SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos);
187 SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); 187 SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize);
188 SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); 188 SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos);
189 189
190 // We need to count number of bits flagged in EventMask? 190 // We need to count number of bits flagged in EventMask?
191 191
192 192
193 // for each bit in myStateFrameBlock.StatePointer[i].EventMask 193 // for each bit in myStateFrameBlock.StatePointer[i].EventMask
194 194
195 // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE 195 // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE
196 //TODO: Create event hooks 196 //TODO: Create event hooks
197 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; 197 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1];
198 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) 198 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++)
199 { 199 {
200 200
201 if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) 201 if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true)
202 { 202 {
203 // We got an event 203 // We got an event
204 // READ: STATE BLOCK HANDLER 204 // READ: STATE BLOCK HANDLER
205 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); 205 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position);
206 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); 206 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0);
207 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); 207 myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0);
208 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); 208 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer);
209 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize ); 209 SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize );
210 } 210 }
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 215
216 216
217 217
218 //// READ FUNCTION CODE CHUNKS 218 //// READ FUNCTION CODE CHUNKS
219 //// Functions + Function start pos (GFR) 219 //// Functions + Function start pos (GFR)
220 //// TODO: Somehow be able to identify and reference this 220 //// TODO: Somehow be able to identify and reference this
221 //LSO_Struct.CodeChunk[] myFunctionCodeChunk; 221 //LSO_Struct.CodeChunk[] myFunctionCodeChunk;
222 //if (myFunctionBlock.FunctionCount > 0) 222 //if (myFunctionBlock.FunctionCount > 0)
223 //{ 223 //{
224 // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; 224 // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount];
225 // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) 225 // for (int i = 0; i < myFunctionBlock.FunctionCount; i++)
226 // { 226 // {
227 // SendToDebug("Reading Function Code Chunk " + i); 227 // SendToDebug("Reading Function Code Chunk " + i);
228 // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); 228 // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]);
229 // } 229 // }
230 230
231 //} 231 //}
232 // READ EVENT CODE CHUNKS 232 // READ EVENT CODE CHUNKS
233 LSO_Struct.CodeChunk[] myEventCodeChunk; 233 LSO_Struct.CodeChunk[] myEventCodeChunk;
234 if (myStateFrameBlock.StateCount > 0) 234 if (myStateFrameBlock.StateCount > 0)
235 { 235 {
236 myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; 236 myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount];
237 for (int i = 0; i < myStateFrameBlock.StateCount; i++) 237 for (int i = 0; i < myStateFrameBlock.StateCount; i++)
238 { 238 {
239 // TODO: Somehow organize events and functions so they can be found again, 239 // TODO: Somehow organize events and functions so they can be found again,
240 // two level search ain't no good 240 // two level search ain't no good
241 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) 241 for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++)
242 { 242 {
243 243
244 244
245 if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) 245 if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0)
246 { 246 {
247 SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); 247 SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii);
248 248
249 249
250 // Override a Method / Function 250 // Override a Method / Function
251 string eventname = "event_" + (LSO_Enums.Event_Mask_Values)ii; 251 string eventname = "event_" + (LSO_Enums.Event_Mask_Values)ii;
252 SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); 252 SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod...");
253 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, 253 MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
254 MethodAttributes.Private | MethodAttributes.Virtual, 254 MethodAttributes.Private | MethodAttributes.Virtual,
255 typeof(void), 255 typeof(void),
256 new Type[] { typeof(object) }); 256 new Type[] { typeof(object) });
257 257
258 SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); 258 SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder...");
259 typeBuilder.DefineMethodOverride(methodBuilder, 259 typeBuilder.DefineMethodOverride(methodBuilder,
260 typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); 260 typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname));
261 261
262 // Create the IL generator 262 // Create the IL generator
263 263
264 SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); 264 SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();");
265 ILGenerator il = methodBuilder.GetILGenerator(); 265 ILGenerator il = methodBuilder.GetILGenerator();
266 266
267 267
268 LSO_Struct.CodeChunk myECC = 268 LSO_Struct.CodeChunk myECC =
269 GetCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, il, eventname); 269 GetCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, il, eventname);
270 } 270 }
271 271
272 } 272 }
273 } 273 }
274 274
275 } 275 }
276 276
277 277
278 // Close 278 // Close
279 br.Close(); 279 br.Close();
280 fs.Close(); 280 fs.Close();
281 281
282 } 282 }
283 283
284 private LSO_Struct.HeapBlock GetHeap(UInt32 pos) 284 private LSO_Struct.HeapBlock GetHeap(UInt32 pos)
285 { 285 {
286 // HEAP BLOCK 286 // HEAP BLOCK
287 // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) 287 // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries)
288 SendToDebug("Reading HEAP BLOCK at: " + pos); 288 SendToDebug("Reading HEAP BLOCK at: " + pos);
289 fs.Seek(pos, SeekOrigin.Begin); 289 fs.Seek(pos, SeekOrigin.Begin);
290 290
291 LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); 291 LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock();
292 myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0); 292 myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0);
293 myHeapBlock.ObjectType = br_read(1)[0]; 293 myHeapBlock.ObjectType = br_read(1)[0];
294 myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); 294 myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0);
295 myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); 295 myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType));
296 296
297 SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); 297 SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize);
298 SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); 298 SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString());
299 SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); 299 SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount);
300 300
301 return myHeapBlock; 301 return myHeapBlock;
302 } 302 }
303 303
304 304
305 305
306 private byte[] br_read(int len) 306 private byte[] br_read(int len)
307 { 307 {
308 if (len <= 0) 308 if (len <= 0)
309 return null; 309 return null;
310 310
311 try 311 try
312 { 312 {
313 byte[] bytes = new byte[len]; 313 byte[] bytes = new byte[len];
314 for (int i = len - 1; i > -1; i--) 314 for (int i = len - 1; i > -1; i--)
315 bytes[i] = br.ReadByte(); 315 bytes[i] = br.ReadByte();
316 return bytes; 316 return bytes;
317 } 317 }
318 catch (Exception e) 318 catch (Exception e)
319 { 319 {
320 SendToDebug("Exception: " + e.ToString()); 320 SendToDebug("Exception: " + e.ToString());
321 throw (e); 321 throw (e);
322 } 322 }
323 } 323 }
324 //private byte[] br_read_smallendian(int len) 324 //private byte[] br_read_smallendian(int len)
325 //{ 325 //{
326 // byte[] bytes = new byte[len]; 326 // byte[] bytes = new byte[len];
327 // br.Read(bytes,0, len); 327 // br.Read(bytes,0, len);
328 // return bytes; 328 // return bytes;
329 //} 329 //}
330 330
331 private int getObjectSize(byte ObjectType) 331 private int getObjectSize(byte ObjectType)
332 { 332 {
333 switch (ObjectType) 333 switch (ObjectType)
334 { 334 {
335 case 1: 335 case 1:
336 case 2: 336 case 2:
337 case 3: 337 case 3:
338 case 4: 338 case 4:
339 case 7: 339 case 7:
340 return 4; 340 return 4;
341 case 5: 341 case 5:
342 return 12; 342 return 12;
343 case 6: 343 case 6:
344 return 16; 344 return 16;
345 default: 345 default:
346 return 0; 346 return 0;
347 } 347 }
348 } 348 }
349 private void SendToDebug(string Message) 349 private void SendToDebug(string Message)
350 { 350 {
351 if (Debug == true) 351 if (Debug == true)
352 Console.WriteLine("Debug: " + Message); 352 Console.WriteLine("Debug: " + Message);
353 } 353 }
354 354
355 355
356 private string Read_String() 356 private string Read_String()
357 { 357 {
358 string ret = ""; 358 string ret = "";
359 byte reader = br_read(1)[0]; 359 byte reader = br_read(1)[0];
360 while (reader != 0x000) 360 while (reader != 0x000)
361 { 361 {
362 ret += (char)reader; 362 ret += (char)reader;
363 reader = br_read(1)[0]; 363 reader = br_read(1)[0];
364 } 364 }
365 return ret; 365 return ret;
366 } 366 }
367 367
368 /// <summary> 368 /// <summary>
369 /// Reads a code chunk into structure and returns it. 369 /// Reads a code chunk into structure and returns it.
370 /// </summary> 370 /// </summary>
371 /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> 371 /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param>
372 /// <returns></returns> 372 /// <returns></returns>
373 private LSO_Struct.CodeChunk GetCodeChunk(UInt32 pos, ILGenerator il, string eventname) 373 private LSO_Struct.CodeChunk GetCodeChunk(UInt32 pos, ILGenerator il, string eventname)
374 { 374 {
375 375
376 /* 376 /*
377 * CLR TRY 377 * CLR TRY
378 */ 378 */
379 //SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); 379 //SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()");
380 il.BeginExceptionBlock(); 380 il.BeginExceptionBlock();
381 381
382 // Push "Hello World!" string to stack 382 // Push "Hello World!" string to stack
383 //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); 383 //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
384 il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); 384 il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname);
385 385
386 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); 386 // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
387 //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 387 //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
388 il.Emit(OpCodes.Call, typeof(Console).GetMethod 388 il.Emit(OpCodes.Call, typeof(Console).GetMethod
389 ("WriteLine", new Type[] { typeof(string) })); 389 ("WriteLine", new Type[] { typeof(string) }));
390 390
391 391
392 LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); 392 LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk();
393 393
394 SendToDebug("Reading Function Code Chunk at: " + pos); 394 SendToDebug("Reading Function Code Chunk at: " + pos);
395 fs.Seek(pos, SeekOrigin.Begin); 395 fs.Seek(pos, SeekOrigin.Begin);
396 myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); 396 myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0);
397 SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize ); 397 SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize );
398 // Read until null 398 // Read until null
399 myCodeChunk.Comment = Read_String(); 399 myCodeChunk.Comment = Read_String();
400 SendToDebug("Function comment: " + myCodeChunk.Comment); 400 SendToDebug("Function comment: " + myCodeChunk.Comment);
401 myCodeChunk.ReturnType = br_read(1)[0]; 401 myCodeChunk.ReturnType = br_read(1)[0];
402 SendToDebug("Return type: " + (LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType); 402 SendToDebug("Return type: " + (LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType);
403 // TODO: How to determine number of codechunks -- does this method work? 403 // TODO: How to determine number of codechunks -- does this method work?
404 myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); 404 myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>();
405 byte reader = br_read(1)[0]; 405 byte reader = br_read(1)[0];
406 reader = br_read(1)[0]; 406 reader = br_read(1)[0];
407 int ccount = 0; 407 int ccount = 0;
408 while (reader != 0x000) 408 while (reader != 0x000)
409 { 409 {
410 ccount++; 410 ccount++;
411 SendToDebug("Reading Code Chunk Argument " + ccount); 411 SendToDebug("Reading Code Chunk Argument " + ccount);
412 LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); 412 LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument();
413 CCA.FunctionReturnType = reader; 413 CCA.FunctionReturnType = reader;
414 reader = br_read(1)[0]; 414 reader = br_read(1)[0];
415 CCA.NullString = reader; 415 CCA.NullString = reader;
416 myCodeChunk.CodeChunkArguments.Add(CCA); 416 myCodeChunk.CodeChunkArguments.Add(CCA);
417 SendToDebug("Code Chunk Argument " + ccount + " return type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType); 417 SendToDebug("Code Chunk Argument " + ccount + " return type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType);
418 } 418 }
419 // End marker is 0x000 419 // End marker is 0x000
420 myCodeChunk.EndMarker = reader; 420 myCodeChunk.EndMarker = reader;
421 // TODO: How to read and identify following code 421 // TODO: How to read and identify following code
422 // TODO: Code is read until a return of some sort is found 422 // TODO: Code is read until a return of some sort is found
423 bool FoundRet = false; 423 bool FoundRet = false;
424 while (FoundRet == false) 424 while (FoundRet == false)
425 { 425 {
426 //reader = br_read(1)[0]; 426 //reader = br_read(1)[0];
427 //UInt16 opcode = BitConverter.ToUInt16(br_read(1),0); 427 //UInt16 opcode = BitConverter.ToUInt16(br_read(1),0);
428 UInt16 opcode = br_read(1)[0]; 428 UInt16 opcode = br_read(1)[0];
429 //long rPos = fs.Position; 429 //long rPos = fs.Position;
430 SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); 430 SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString());
431 switch (opcode) 431 switch (opcode)
432 { 432 {
433 // LONG 433 // LONG
434 case (UInt16)LSO_Enums.Operation_Table.POPARG: 434 case (UInt16)LSO_Enums.Operation_Table.POPARG:
435 case (UInt16)LSO_Enums.Operation_Table.STORE: 435 case (UInt16)LSO_Enums.Operation_Table.STORE:
436 case (UInt16)LSO_Enums.Operation_Table.STORES: 436 case (UInt16)LSO_Enums.Operation_Table.STORES:
437 case (UInt16)LSO_Enums.Operation_Table.STOREL: 437 case (UInt16)LSO_Enums.Operation_Table.STOREL:
438 case (UInt16)LSO_Enums.Operation_Table.STOREV: 438 case (UInt16)LSO_Enums.Operation_Table.STOREV:
439 case (UInt16)LSO_Enums.Operation_Table.STOREQ: 439 case (UInt16)LSO_Enums.Operation_Table.STOREQ:
440 case (UInt16)LSO_Enums.Operation_Table.STOREG: 440 case (UInt16)LSO_Enums.Operation_Table.STOREG:
441 case (UInt16)LSO_Enums.Operation_Table.STOREGS: 441 case (UInt16)LSO_Enums.Operation_Table.STOREGS:
442 case (UInt16)LSO_Enums.Operation_Table.STOREGL: 442 case (UInt16)LSO_Enums.Operation_Table.STOREGL:
443 case (UInt16)LSO_Enums.Operation_Table.STOREGV: 443 case (UInt16)LSO_Enums.Operation_Table.STOREGV:
444 case (UInt16)LSO_Enums.Operation_Table.STOREGQ: 444 case (UInt16)LSO_Enums.Operation_Table.STOREGQ:
445 case (UInt16)LSO_Enums.Operation_Table.LOADP: 445 case (UInt16)LSO_Enums.Operation_Table.LOADP:
446 case (UInt16)LSO_Enums.Operation_Table.LOADSP: 446 case (UInt16)LSO_Enums.Operation_Table.LOADSP:
447 case (UInt16)LSO_Enums.Operation_Table.LOADLP: 447 case (UInt16)LSO_Enums.Operation_Table.LOADLP:
448 case (UInt16)LSO_Enums.Operation_Table.LOADVP: 448 case (UInt16)LSO_Enums.Operation_Table.LOADVP:
449 case (UInt16)LSO_Enums.Operation_Table.LOADQP: 449 case (UInt16)LSO_Enums.Operation_Table.LOADQP:
450 case (UInt16)LSO_Enums.Operation_Table.PUSH: 450 case (UInt16)LSO_Enums.Operation_Table.PUSH:
451 case (UInt16)LSO_Enums.Operation_Table.PUSHS: 451 case (UInt16)LSO_Enums.Operation_Table.PUSHS:
452 case (UInt16)LSO_Enums.Operation_Table.PUSHL: 452 case (UInt16)LSO_Enums.Operation_Table.PUSHL:
453 case (UInt16)LSO_Enums.Operation_Table.PUSHV: 453 case (UInt16)LSO_Enums.Operation_Table.PUSHV:
454 case (UInt16)LSO_Enums.Operation_Table.PUSHQ: 454 case (UInt16)LSO_Enums.Operation_Table.PUSHQ:
455 case (UInt16)LSO_Enums.Operation_Table.PUSHG: 455 case (UInt16)LSO_Enums.Operation_Table.PUSHG:
456 case (UInt16)LSO_Enums.Operation_Table.PUSHGS: 456 case (UInt16)LSO_Enums.Operation_Table.PUSHGS:
457 case (UInt16)LSO_Enums.Operation_Table.PUSHGL: 457 case (UInt16)LSO_Enums.Operation_Table.PUSHGL:
458 case (UInt16)LSO_Enums.Operation_Table.PUSHGV: 458 case (UInt16)LSO_Enums.Operation_Table.PUSHGV:
459 case (UInt16)LSO_Enums.Operation_Table.PUSHGQ: 459 case (UInt16)LSO_Enums.Operation_Table.PUSHGQ:
460 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 460 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
461 break; 461 break;
462 // BYTE 462 // BYTE
463 case (UInt16)LSO_Enums.Operation_Table.PUSHARGB: 463 case (UInt16)LSO_Enums.Operation_Table.PUSHARGB:
464 SendToDebug("Param1: " + br_read(1)[0]); 464 SendToDebug("Param1: " + br_read(1)[0]);
465 break; 465 break;
466 // INTEGER 466 // INTEGER
467 case (UInt16)LSO_Enums.Operation_Table.PUSHARGI: 467 case (UInt16)LSO_Enums.Operation_Table.PUSHARGI:
468 // TODO: What is size of integer? 468 // TODO: What is size of integer?
469 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 469 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
470 break; 470 break;
471 // FLOAT 471 // FLOAT
472 case (UInt16)LSO_Enums.Operation_Table.PUSHARGF: 472 case (UInt16)LSO_Enums.Operation_Table.PUSHARGF:
473 // TODO: What is size of float? 473 // TODO: What is size of float?
474 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 474 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
475 break; 475 break;
476 // STRING 476 // STRING
477 case (UInt16)LSO_Enums.Operation_Table.PUSHARGS: 477 case (UInt16)LSO_Enums.Operation_Table.PUSHARGS:
478 string s = Read_String(); 478 string s = Read_String();
479 SendToDebug("Param1: " + s); 479 SendToDebug("Param1: " + s);
480 il.Emit(OpCodes.Ldstr, s); 480 il.Emit(OpCodes.Ldstr, s);
481 break; 481 break;
482 // VECTOR z,y,x 482 // VECTOR z,y,x
483 case (UInt16)LSO_Enums.Operation_Table.PUSHARGV: 483 case (UInt16)LSO_Enums.Operation_Table.PUSHARGV:
484 SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); 484 SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0));
485 SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); 485 SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0));
486 SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); 486 SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0));
487 break; 487 break;
488 // ROTATION s,z,y,x 488 // ROTATION s,z,y,x
489 case (UInt16)LSO_Enums.Operation_Table.PUSHARGQ: 489 case (UInt16)LSO_Enums.Operation_Table.PUSHARGQ:
490 SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4),0)); 490 SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4),0));
491 SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); 491 SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0));
492 SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); 492 SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0));
493 SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); 493 SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0));
494 break; 494 break;
495 // LONG 495 // LONG
496 case (UInt16)LSO_Enums.Operation_Table.PUSHARGE: 496 case (UInt16)LSO_Enums.Operation_Table.PUSHARGE:
497 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 497 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
498 break; 498 break;
499 // BYTE 499 // BYTE
500 case (UInt16)LSO_Enums.Operation_Table.ADD: 500 case (UInt16)LSO_Enums.Operation_Table.ADD:
501 case (UInt16)LSO_Enums.Operation_Table.SUB: 501 case (UInt16)LSO_Enums.Operation_Table.SUB:
502 case (UInt16)LSO_Enums.Operation_Table.MUL: 502 case (UInt16)LSO_Enums.Operation_Table.MUL:
503 case (UInt16)LSO_Enums.Operation_Table.DIV: 503 case (UInt16)LSO_Enums.Operation_Table.DIV:
504 case (UInt16)LSO_Enums.Operation_Table.MOD: 504 case (UInt16)LSO_Enums.Operation_Table.MOD:
505 case (UInt16)LSO_Enums.Operation_Table.EQ: 505 case (UInt16)LSO_Enums.Operation_Table.EQ:
506 case (UInt16)LSO_Enums.Operation_Table.NEQ: 506 case (UInt16)LSO_Enums.Operation_Table.NEQ:
507 case (UInt16)LSO_Enums.Operation_Table.LEQ: 507 case (UInt16)LSO_Enums.Operation_Table.LEQ:
508 case (UInt16)LSO_Enums.Operation_Table.GEQ: 508 case (UInt16)LSO_Enums.Operation_Table.GEQ:
509 case (UInt16)LSO_Enums.Operation_Table.LESS: 509 case (UInt16)LSO_Enums.Operation_Table.LESS:
510 case (UInt16)LSO_Enums.Operation_Table.GREATER: 510 case (UInt16)LSO_Enums.Operation_Table.GREATER:
511 case (UInt16)LSO_Enums.Operation_Table.BOOLOR: 511 case (UInt16)LSO_Enums.Operation_Table.BOOLOR:
512 SendToDebug("Param1: " + br_read(1)[0]); 512 SendToDebug("Param1: " + br_read(1)[0]);
513 break; 513 break;
514 // LONG 514 // LONG
515 case (UInt16)LSO_Enums.Operation_Table.JUMP: 515 case (UInt16)LSO_Enums.Operation_Table.JUMP:
516 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 516 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
517 break; 517 break;
518 // BYTE, LONG 518 // BYTE, LONG
519 case (UInt16)LSO_Enums.Operation_Table.JUMPIF: 519 case (UInt16)LSO_Enums.Operation_Table.JUMPIF:
520 case (UInt16)LSO_Enums.Operation_Table.JUMPNIF: 520 case (UInt16)LSO_Enums.Operation_Table.JUMPNIF:
521 SendToDebug("Param1: " + br_read(1)[0]); 521 SendToDebug("Param1: " + br_read(1)[0]);
522 SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4),0)); 522 SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4),0));
523 break; 523 break;
524 // LONG 524 // LONG
525 case (UInt16)LSO_Enums.Operation_Table.STATE: 525 case (UInt16)LSO_Enums.Operation_Table.STATE:
526 case (UInt16)LSO_Enums.Operation_Table.CALL: 526 case (UInt16)LSO_Enums.Operation_Table.CALL:
527 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 527 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
528 break; 528 break;
529 // BYTE 529 // BYTE
530 case (UInt16)LSO_Enums.Operation_Table.CAST: 530 case (UInt16)LSO_Enums.Operation_Table.CAST:
531 SendToDebug("Param1: " + br_read(1)[0]); 531 SendToDebug("Param1: " + br_read(1)[0]);
532 break; 532 break;
533 // LONG 533 // LONG
534 case (UInt16)LSO_Enums.Operation_Table.STACKTOS: 534 case (UInt16)LSO_Enums.Operation_Table.STACKTOS:
535 case (UInt16)LSO_Enums.Operation_Table.STACKTOL: 535 case (UInt16)LSO_Enums.Operation_Table.STACKTOL:
536 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); 536 SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
537 break; 537 break;
538 // BYTE 538 // BYTE
539 case (UInt16)LSO_Enums.Operation_Table.PRINT: 539 case (UInt16)LSO_Enums.Operation_Table.PRINT:
540 case (UInt16)LSO_Enums.Operation_Table.CALLLIB: 540 case (UInt16)LSO_Enums.Operation_Table.CALLLIB:
541 SendToDebug("Param1: " + br_read(1)[0]); 541 SendToDebug("Param1: " + br_read(1)[0]);
542 break; 542 break;
543 // SHORT 543 // SHORT
544 case (UInt16)LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: 544 case (UInt16)LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
545 // TODO: What is size of short? 545 // TODO: What is size of short?
546 UInt16 _i = BitConverter.ToUInt16(br_read(2), 0); 546 UInt16 _i = BitConverter.ToUInt16(br_read(2), 0);
547 SendToDebug("Param1: " + _i); 547 SendToDebug("Param1: " + _i);
548 switch (_i) 548 switch (_i)
549 { 549 {
550 case (UInt16)LSO_Enums.BuiltIn_Functions.llSay: 550 case (UInt16)LSO_Enums.BuiltIn_Functions.llSay:
551 il.Emit(OpCodes.Call, typeof(Console).GetMethod 551 il.Emit(OpCodes.Call, typeof(Console).GetMethod
552 ("WriteLine", new Type[] { typeof(string) })); 552 ("WriteLine", new Type[] { typeof(string) }));
553 break; 553 break;
554 } 554 }
555 break; 555 break;
556 556
557 557
558 // RETURN 558 // RETURN
559 case (UInt16)LSO_Enums.Operation_Table.RETURN: 559 case (UInt16)LSO_Enums.Operation_Table.RETURN:
560 SendToDebug("Last OPCODE was return command. Code chunk execution complete."); 560 SendToDebug("Last OPCODE was return command. Code chunk execution complete.");
561 FoundRet = true; 561 FoundRet = true;
562 break; 562 break;
563 } 563 }
564 //fs.Seek(rPos, SeekOrigin.Begin); 564 //fs.Seek(rPos, SeekOrigin.Begin);
565 565
566 } 566 }
567 567
568 568
569 /* 569 /*
570 * CATCH 570 * CATCH
571 */ 571 */
572 SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); 572 SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));");
573 il.BeginCatchBlock(typeof(Exception)); 573 il.BeginCatchBlock(typeof(Exception));
574 574
575 // Push "Hello World!" string to stack 575 // Push "Hello World!" string to stack
576 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); 576 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
577 il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); 577 il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": ");
578 578
579 //call void [mscorlib]System.Console::WriteLine(string) 579 //call void [mscorlib]System.Console::WriteLine(string)
580 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 580 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
581 il.Emit(OpCodes.Call, typeof(Console).GetMethod 581 il.Emit(OpCodes.Call, typeof(Console).GetMethod
582 ("Write", new Type[] { typeof(string) })); 582 ("Write", new Type[] { typeof(string) }));
583 583
584 //callvirt instance string [mscorlib]System.Exception::get_Message() 584 //callvirt instance string [mscorlib]System.Exception::get_Message()
585 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); 585 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt...");
586 il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod 586 il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod
587 ("get_Message")); 587 ("get_Message"));
588 588
589 //call void [mscorlib]System.Console::WriteLine(string) 589 //call void [mscorlib]System.Console::WriteLine(string)
590 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); 590 SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
591 il.Emit(OpCodes.Call, typeof(Console).GetMethod 591 il.Emit(OpCodes.Call, typeof(Console).GetMethod
592 ("WriteLine", new Type[] { typeof(string) })); 592 ("WriteLine", new Type[] { typeof(string) }));
593 593
594 /* 594 /*
595 * CLR END TRY 595 * CLR END TRY
596 */ 596 */
597 //SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); 597 //SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();");
598 il.EndExceptionBlock(); 598 il.EndExceptionBlock();
599 // Push "Return from current method, with return value if present" to stack 599 // Push "Return from current method, with return value if present" to stack
600 il.Emit(OpCodes.Ret); 600 il.Emit(OpCodes.Ret);
601 601
602 602
603 603
604 return myCodeChunk; 604 return myCodeChunk;
605 605
606 } 606 }
607 } 607 }
608} 608}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs
index 3b91e9f..66c6c5e 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs
@@ -1,105 +1,105 @@
1 1
2using System; 2using System;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using System.Text; 4using System.Text;
5 5
6namespace OpenSim.ScriptEngines.LSL 6namespace OpenSim.ScriptEngines.LSL
7{ 7{
8 static class LSO_Struct 8 static class LSO_Struct
9 { 9 {
10 10
11 public struct Header 11 public struct Header
12 { 12 {
13 public UInt32 TM; 13 public UInt32 TM;
14 public UInt32 IP; 14 public UInt32 IP;
15 public UInt32 VN; 15 public UInt32 VN;
16 public UInt32 BP; 16 public UInt32 BP;
17 public UInt32 SP; 17 public UInt32 SP;
18 public UInt32 HR; 18 public UInt32 HR;
19 public UInt32 HP; 19 public UInt32 HP;
20 public UInt32 CS; 20 public UInt32 CS;
21 public UInt32 NS; 21 public UInt32 NS;
22 public UInt32 CE; 22 public UInt32 CE;
23 public UInt32 IE; 23 public UInt32 IE;
24 public UInt32 ER; 24 public UInt32 ER;
25 public UInt32 FR; 25 public UInt32 FR;
26 public UInt32 SLR; 26 public UInt32 SLR;
27 public UInt32 GVR; 27 public UInt32 GVR;
28 public UInt32 GFR; 28 public UInt32 GFR;
29 public UInt32 PR; 29 public UInt32 PR;
30 public UInt32 ESR; 30 public UInt32 ESR;
31 public UInt32 SR; 31 public UInt32 SR;
32 public UInt64 NCE; 32 public UInt64 NCE;
33 public UInt64 NIE; 33 public UInt64 NIE;
34 public UInt64 NER; 34 public UInt64 NER;
35 } 35 }
36 36
37 public struct StaticBlock 37 public struct StaticBlock
38 { 38 {
39 public UInt32 Static_Chunk_Header_Size; 39 public UInt32 Static_Chunk_Header_Size;
40 public byte ObjectType; 40 public byte ObjectType;
41 public byte Unknown; 41 public byte Unknown;
42 public byte[] BlockVariable; 42 public byte[] BlockVariable;
43 } 43 }
44 /* Not actually a structure 44 /* Not actually a structure
45 public struct StaticBlockVariable 45 public struct StaticBlockVariable
46 { 46 {
47 public UInt32 Integer1; 47 public UInt32 Integer1;
48 public UInt32 Float1; 48 public UInt32 Float1;
49 public UInt32 HeapPointer_String; 49 public UInt32 HeapPointer_String;
50 public UInt32 HeapPointer_Key; 50 public UInt32 HeapPointer_Key;
51 public byte[] Vector_12; 51 public byte[] Vector_12;
52 public byte[] Rotation_16; 52 public byte[] Rotation_16;
53 public UInt32 Pointer_List_Structure; 53 public UInt32 Pointer_List_Structure;
54 } */ 54 } */
55 public struct HeapBlock 55 public struct HeapBlock
56 { 56 {
57 public UInt32 DataBlockSize; 57 public UInt32 DataBlockSize;
58 public byte ObjectType; 58 public byte ObjectType;
59 public UInt16 ReferenceCount; 59 public UInt16 ReferenceCount;
60 public byte[] Data; 60 public byte[] Data;
61 } 61 }
62 public struct StateFrameBlock 62 public struct StateFrameBlock
63 { 63 {
64 public UInt32 StateCount; 64 public UInt32 StateCount;
65 public StatePointerBlock[] StatePointer; 65 public StatePointerBlock[] StatePointer;
66 } 66 }
67 public struct StatePointerBlock 67 public struct StatePointerBlock
68 { 68 {
69 public UInt32 Location; 69 public UInt32 Location;
70 public System.Collections.BitArray EventMask; 70 public System.Collections.BitArray EventMask;
71 public StateBlock StateBlock; 71 public StateBlock StateBlock;
72 } 72 }
73 public struct StateBlock 73 public struct StateBlock
74 { 74 {
75 public UInt32 StartPos; 75 public UInt32 StartPos;
76 public UInt32 EndPos; 76 public UInt32 EndPos;
77 public UInt32 HeaderSize; 77 public UInt32 HeaderSize;
78 public byte Unknown; 78 public byte Unknown;
79 public StateBlockHandler[] StateBlockHandlers; 79 public StateBlockHandler[] StateBlockHandlers;
80 } 80 }
81 public struct StateBlockHandler 81 public struct StateBlockHandler
82 { 82 {
83 public UInt32 CodeChunkPointer; 83 public UInt32 CodeChunkPointer;
84 public UInt32 CallFrameSize; 84 public UInt32 CallFrameSize;
85 } 85 }
86 public struct FunctionBlock 86 public struct FunctionBlock
87 { 87 {
88 public UInt32 FunctionCount; 88 public UInt32 FunctionCount;
89 public UInt32[] CodeChunkPointer; 89 public UInt32[] CodeChunkPointer;
90 } 90 }
91 public struct CodeChunk 91 public struct CodeChunk
92 { 92 {
93 public UInt32 CodeChunkHeaderSize; 93 public UInt32 CodeChunkHeaderSize;
94 public string Comment; 94 public string Comment;
95 public System.Collections.Generic.List<CodeChunkArgument> CodeChunkArguments; 95 public System.Collections.Generic.List<CodeChunkArgument> CodeChunkArguments;
96 public byte EndMarker; 96 public byte EndMarker;
97 public byte ReturnType; 97 public byte ReturnType;
98 } 98 }
99 public struct CodeChunkArgument 99 public struct CodeChunkArgument
100 { 100 {
101 public byte FunctionReturnType; 101 public byte FunctionReturnType;
102 public byte NullString; 102 public byte NullString;
103 } 103 }
104 } 104 }
105} 105}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Script.cs b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
index 99d7d04..40825c0 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Script.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
@@ -1,64 +1,64 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using OpenSim.Region.Environment.Scenes; 28using OpenSim.Region.Environment.Scenes;
29 29
30namespace OpenSim.Region.Scripting 30namespace OpenSim.Region.Scripting
31{ 31{
32 public interface IScript 32 public interface IScript
33 { 33 {
34 void Initialise(ScriptInfo scriptInfo); 34 void Initialise(ScriptInfo scriptInfo);
35 string getName(); 35 string getName();
36 } 36 }
37 37
38 public class TestScript : IScript 38 public class TestScript : IScript
39 { 39 {
40 ScriptInfo script; 40 ScriptInfo script;
41 41
42 public string getName() 42 public string getName()
43 { 43 {
44 return "TestScript 0.1"; 44 return "TestScript 0.1";
45 } 45 }
46 46
47 public void Initialise(ScriptInfo scriptInfo) 47 public void Initialise(ScriptInfo scriptInfo)
48 { 48 {
49 script = scriptInfo; 49 script = scriptInfo;
50 script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); 50 script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
51 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); 51 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
52 } 52 }
53 53
54 void events_OnNewPresence(ScenePresence presence) 54 void events_OnNewPresence(ScenePresence presence)
55 { 55 {
56 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); 56 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
57 } 57 }
58 58
59 void events_OnFrame() 59 void events_OnFrame()
60 { 60 {
61 //script.logger.Verbose("Hello World!"); 61 //script.logger.Verbose("Hello World!");
62 } 62 }
63 } 63 }
64} 64}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
index a8f6aa5..b4f6a05 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
@@ -1,32 +1,32 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using Key = libsecondlife.LLUUID; 4using Key = libsecondlife.LLUUID;
5using Rotation = libsecondlife.LLQuaternion; 5using Rotation = libsecondlife.LLQuaternion;
6using Vector = libsecondlife.LLVector3; 6using Vector = libsecondlife.LLVector3;
7using LSLList = System.Collections.Generic.List<string>; 7using LSLList = System.Collections.Generic.List<string>;
8 8
9 9
10using OpenSim.Region.Environment.Scenes; 10using OpenSim.Region.Environment.Scenes;
11 11
12namespace OpenSim.Region.Scripting 12namespace OpenSim.Region.Scripting
13{ 13{
14 // This class is to be used for engines which may not be able to access the Scene directly. 14 // This class is to be used for engines which may not be able to access the Scene directly.
15 // Scene access is preffered, but obviously not possible on some non-.NET languages. 15 // Scene access is preffered, but obviously not possible on some non-.NET languages.
16 public class ScriptAPI 16 public class ScriptAPI
17 { 17 {
18 Scene scene; 18 Scene scene;
19 ScriptInterpretedAPI interpretedAPI; 19 ScriptInterpretedAPI interpretedAPI;
20 20
21 public ScriptAPI(Scene world) 21 public ScriptAPI(Scene world)
22 { 22 {
23 scene = world; 23 scene = world;
24 interpretedAPI = new ScriptInterpretedAPI(); 24 interpretedAPI = new ScriptInterpretedAPI();
25 } 25 }
26 26
27 public Object CallMethod(String method, Object[] args) 27 public Object CallMethod(String method, Object[] args)
28 { 28 {
29 return null; 29 return null;
30 } 30 }
31 } 31 }
32} 32}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
index c3be22a..4a6086c 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
@@ -1,58 +1,58 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using OpenSim.Framework.Console; 28using OpenSim.Framework.Console;
29using OpenSim.Region.Environment.Scenes; 29using OpenSim.Region.Environment.Scenes;
30 30
31namespace OpenSim.Region.Scripting 31namespace OpenSim.Region.Scripting
32{ 32{
33 /// <summary> 33 /// <summary>
34 /// Class which provides access to the world 34 /// Class which provides access to the world
35 /// </summary> 35 /// </summary>
36 public class ScriptInfo 36 public class ScriptInfo
37 { 37 {
38 // Reference to world.eventsManager provided for convenience 38 // Reference to world.eventsManager provided for convenience
39 public EventManager events; 39 public EventManager events;
40 40
41 // The main world 41 // The main world
42 public Scene world; 42 public Scene world;
43 43
44 // The console 44 // The console
45 public LogBase logger; 45 public LogBase logger;
46 46
47 // API Access 47 // API Access
48 public ScriptAPI api; 48 public ScriptAPI api;
49 49
50 public ScriptInfo(Scene scene) 50 public ScriptInfo(Scene scene)
51 { 51 {
52 world = scene; 52 world = scene;
53 events = world.EventManager; 53 events = world.EventManager;
54 logger = MainLog.Instance; 54 logger = MainLog.Instance;
55 api = new ScriptAPI(scene); 55 api = new ScriptAPI(scene);
56 } 56 }
57 } 57 }
58} 58}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs
index 085d97e..b4a6019 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs
@@ -1,206 +1,206 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using Key = libsecondlife.LLUUID; 4using Key = libsecondlife.LLUUID;
5using Rotation = libsecondlife.LLQuaternion; 5using Rotation = libsecondlife.LLQuaternion;
6using Vector = libsecondlife.LLVector3; 6using Vector = libsecondlife.LLVector3;
7using LSLList = System.Collections.Generic.List<string>; 7using LSLList = System.Collections.Generic.List<string>;
8 8
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10 10
11namespace OpenSim.Region.Scripting 11namespace OpenSim.Region.Scripting
12{ 12{
13 /// <summary> 13 /// <summary>
14 /// A class inteded to act as an API for LSL-styled interpreted languages 14 /// A class inteded to act as an API for LSL-styled interpreted languages
15 /// </summary> 15 /// </summary>
16 /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks> 16 /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks>
17 class ScriptInterpretedAPI 17 class ScriptInterpretedAPI
18 { 18 {
19 public int osAbs(int val) 19 public int osAbs(int val)
20 { 20 {
21 return Math.Abs(val); 21 return Math.Abs(val);
22 } 22 }
23 23
24 public float osAcos(float val) 24 public float osAcos(float val)
25 { 25 {
26 return (float)Math.Acos(val); 26 return (float)Math.Acos(val);
27 } 27 }
28 28
29 [Obsolete("Unimplemented")] 29 [Obsolete("Unimplemented")]
30 public void osAddToLandPassList(Key avatar, float hours) 30 public void osAddToLandPassList(Key avatar, float hours)
31 { 31 {
32 OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); 32 OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)");
33 return; 33 return;
34 } 34 }
35 35
36 [Obsolete("Unimplemented")] 36 [Obsolete("Unimplemented")]
37 public void osAdjustSoundVolume(float volume) 37 public void osAdjustSoundVolume(float volume)
38 { 38 {
39 OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)"); 39 OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)");
40 return; 40 return;
41 } 41 }
42 42
43 [Obsolete("Unimplemented")] 43 [Obsolete("Unimplemented")]
44 public void osAllowInventoryDrop(int add) 44 public void osAllowInventoryDrop(int add)
45 { 45 {
46 return; 46 return;
47 } 47 }
48 48
49 [Obsolete("Unimplemented")] 49 [Obsolete("Unimplemented")]
50 public float osAngleBetween(Rotation a, Rotation b) 50 public float osAngleBetween(Rotation a, Rotation b)
51 { 51 {
52 Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); 52 Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z);
53 Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); 53 Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z);
54 54
55 return 0; 55 return 0;
56 } 56 }
57 57
58 [Obsolete("Unimplemented")] 58 [Obsolete("Unimplemented")]
59 public void osApplyImpulse(Vector force, int local) 59 public void osApplyImpulse(Vector force, int local)
60 { 60 {
61 return; 61 return;
62 } 62 }
63 63
64 [Obsolete("Unimplemented")] 64 [Obsolete("Unimplemented")]
65 public void osApplyRotationalImpulse(Vector force, int local) 65 public void osApplyRotationalImpulse(Vector force, int local)
66 { 66 {
67 return; 67 return;
68 } 68 }
69 69
70 public float osAsin(float val) 70 public float osAsin(float val)
71 { 71 {
72 return (float)Math.Asin(val); 72 return (float)Math.Asin(val);
73 } 73 }
74 74
75 public float osAtan2(float x, float y) 75 public float osAtan2(float x, float y)
76 { 76 {
77 return (float)Math.Atan2(x, y); 77 return (float)Math.Atan2(x, y);
78 } 78 }
79 79
80 [Obsolete("Unimplemented")] 80 [Obsolete("Unimplemented")]
81 public void osAttachToAvatar(Key avatar, int attachmentPoint) 81 public void osAttachToAvatar(Key avatar, int attachmentPoint)
82 { 82 {
83 return; 83 return;
84 } 84 }
85 85
86 [Obsolete("Unimplemented")] 86 [Obsolete("Unimplemented")]
87 public Key osAvatarOnSitTarget() 87 public Key osAvatarOnSitTarget()
88 { 88 {
89 return Key.Zero; 89 return Key.Zero;
90 } 90 }
91 91
92 public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) 92 public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up)
93 { 93 {
94 Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); 94 Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion();
95 Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); 95 Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z);
96 Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); 96 Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z);
97 Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); 97 Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z);
98 98
99 axQ.FromAxes(axFwd, axLeft, axUp); 99 axQ.FromAxes(axFwd, axLeft, axUp);
100 100
101 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); 101 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w);
102 } 102 }
103 103
104 public Rotation osAxisAngle2Rot(Vector axis, float angle) 104 public Rotation osAxisAngle2Rot(Vector axis, float angle)
105 { 105 {
106 Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); 106 Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z));
107 107
108 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); 108 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w);
109 } 109 }
110 110
111 public string osBase64ToString(string str) 111 public string osBase64ToString(string str)
112 { 112 {
113 Encoding enc = System.Text.Encoding.UTF8; 113 Encoding enc = System.Text.Encoding.UTF8;
114 return enc.GetString(Convert.FromBase64String(str)); 114 return enc.GetString(Convert.FromBase64String(str));
115 } 115 }
116 116
117 [Obsolete("Unimplemented")] 117 [Obsolete("Unimplemented")]
118 public void osBreakAllLinks() 118 public void osBreakAllLinks()
119 { 119 {
120 return; 120 return;
121 } 121 }
122 122
123 [Obsolete("Unimplemented")] 123 [Obsolete("Unimplemented")]
124 public void osBreakLink() 124 public void osBreakLink()
125 { 125 {
126 return; 126 return;
127 } 127 }
128 128
129 public LSLList osCSV2List(string src) 129 public LSLList osCSV2List(string src)
130 { 130 {
131 LSLList retVal = new LSLList(); 131 LSLList retVal = new LSLList();
132 retVal.AddRange(src.Split(',')); 132 retVal.AddRange(src.Split(','));
133 133
134 return retVal; 134 return retVal;
135 } 135 }
136 136
137 public int osCeil(float val) 137 public int osCeil(float val)
138 { 138 {
139 return (int)Math.Ceiling(val); 139 return (int)Math.Ceiling(val);
140 } 140 }
141 141
142 [Obsolete("Unimplemented")] 142 [Obsolete("Unimplemented")]
143 public void osCloseRemoteDataChannel(Key channel) 143 public void osCloseRemoteDataChannel(Key channel)
144 { 144 {
145 return; 145 return;
146 } 146 }
147 147
148 [Obsolete("Unimplemented")] 148 [Obsolete("Unimplemented")]
149 public float osCloud(Vector offset) 149 public float osCloud(Vector offset)
150 { 150 {
151 return 0.0f; 151 return 0.0f;
152 } 152 }
153 153
154 [Obsolete("Unimplemented")] 154 [Obsolete("Unimplemented")]
155 public void osCollisionFilter(string name, Key id, int accept) 155 public void osCollisionFilter(string name, Key id, int accept)
156 { 156 {
157 return; 157 return;
158 } 158 }
159 159
160 [Obsolete("Unimplemented")] 160 [Obsolete("Unimplemented")]
161 public void osCollisionSprite(string impact_sprite) 161 public void osCollisionSprite(string impact_sprite)
162 { 162 {
163 return; 163 return;
164 } 164 }
165 165
166 public float osCos(float theta) 166 public float osCos(float theta)
167 { 167 {
168 return (float)Math.Cos(theta); 168 return (float)Math.Cos(theta);
169 } 169 }
170 170
171 [Obsolete("Unimplemented")] 171 [Obsolete("Unimplemented")]
172 public void osCreateLink(Key target, int parent) 172 public void osCreateLink(Key target, int parent)
173 { 173 {
174 return; 174 return;
175 } 175 }
176 176
177 [Obsolete("Partially Unimplemented")] 177 [Obsolete("Partially Unimplemented")]
178 public LSLList osDeleteSubList(LSLList src, int start, int end) 178 public LSLList osDeleteSubList(LSLList src, int start, int end)
179 { 179 {
180 if (start < 0 || end < 0) 180 if (start < 0 || end < 0)
181 { 181 {
182 throw new Exception("Unsupported at this time."); 182 throw new Exception("Unsupported at this time.");
183 } 183 }
184 184
185 src.RemoveRange(start, start - end + 1); 185 src.RemoveRange(start, start - end + 1);
186 return src; 186 return src;
187 } 187 }
188 188
189 [Obsolete("Partially Unimplemented")] 189 [Obsolete("Partially Unimplemented")]
190 public string osDeleteSubString(string src, int start, int end) 190 public string osDeleteSubString(string src, int start, int end)
191 { 191 {
192 if (start < 0 || end < 0) 192 if (start < 0 || end < 0)
193 { 193 {
194 throw new Exception("Unsupported at this time."); 194 throw new Exception("Unsupported at this time.");
195 } 195 }
196 196
197 return src.Remove(start, start - end + 1); 197 return src.Remove(start, start - end + 1);
198 } 198 }
199 199
200 [Obsolete("Unimplemented")] 200 [Obsolete("Unimplemented")]
201 public void osDetachFromAvatar(Key avatar) 201 public void osDetachFromAvatar(Key avatar)
202 { 202 {
203 return; 203 return;
204 } 204 }
205 } 205 }
206} 206}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs
index 7743186..d6456a6 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs
@@ -1,16 +1,16 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Region.Environment.Scenes; 4using OpenSim.Region.Environment.Scenes;
5using libsecondlife; 5using libsecondlife;
6using Key = libsecondlife.LLUUID; 6using Key = libsecondlife.LLUUID;
7 7
8namespace OpenSim.Region.Scripting 8namespace OpenSim.Region.Scripting
9{ 9{
10 10
11 public class ScriptInterpretedEvents 11 public class ScriptInterpretedEvents
12 { 12 {
13 public delegate void OnTouchStartDelegate(Key user); 13 public delegate void OnTouchStartDelegate(Key user);
14 public event OnTouchStartDelegate OnTouchStart; 14 public event OnTouchStartDelegate OnTouchStart;
15 } 15 }
16} 16}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
index 7a08735..27e831b 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
@@ -1,107 +1,107 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using OpenSim.Framework.Console; 29using OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
31 31
32namespace OpenSim.Region.Scripting 32namespace OpenSim.Region.Scripting
33{ 33{
34 public class ScriptManager 34 public class ScriptManager
35 { 35 {
36 List<IScript> scripts = new List<IScript>(); 36 List<IScript> scripts = new List<IScript>();
37 Scene scene; 37 Scene scene;
38 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>(); 38 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
39 39
40 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts) 40 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
41 { 41 {
42 foreach (KeyValuePair<string, IScript> script in compiledscripts) 42 foreach (KeyValuePair<string, IScript> script in compiledscripts)
43 { 43 {
44 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. 44 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
45 MainLog.Instance.Verbose("Loading " + script.Key); 45 MainLog.Instance.Verbose("Loading " + script.Key);
46 script.Value.Initialise(scriptInfo); 46 script.Value.Initialise(scriptInfo);
47 scripts.Add(script.Value); 47 scripts.Add(script.Value);
48 } 48 }
49 MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); 49 MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)");
50 } 50 }
51 51
52 public ScriptManager(Scene world) 52 public ScriptManager(Scene world)
53 { 53 {
54 scene = world; 54 scene = world;
55 55
56 // Default Engines 56 // Default Engines
57 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); 57 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
58 compilers.Add(csharpCompiler.FileExt(),csharpCompiler); 58 compilers.Add(csharpCompiler.FileExt(),csharpCompiler);
59 59
60 JScriptEngine jscriptCompiler = new JScriptEngine(); 60 JScriptEngine jscriptCompiler = new JScriptEngine();
61 compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); 61 compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
62 62
63 JavaEngine javaCompiler = new JavaEngine(); 63 JavaEngine javaCompiler = new JavaEngine();
64 compilers.Add(javaCompiler.FileExt(), javaCompiler); 64 compilers.Add(javaCompiler.FileExt(), javaCompiler);
65 } 65 }
66 66
67 public void Compile(string filename) 67 public void Compile(string filename)
68 { 68 {
69 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers) 69 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
70 { 70 {
71 if (filename.EndsWith(compiler.Key)) 71 if (filename.EndsWith(compiler.Key))
72 { 72 {
73 LoadFromCompiler(compiler.Value.compile(filename)); 73 LoadFromCompiler(compiler.Value.compile(filename));
74 break; 74 break;
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 public void RunScriptCmd(string[] args) 79 public void RunScriptCmd(string[] args)
80 { 80 {
81 switch (args[0]) 81 switch (args[0])
82 { 82 {
83 case "load": 83 case "load":
84 Compile(args[1]); 84 Compile(args[1]);
85 break; 85 break;
86 86
87 default: 87 default:
88 MainLog.Instance.Error("Unknown script command"); 88 MainLog.Instance.Error("Unknown script command");
89 break; 89 break;
90 } 90 }
91 } 91 }
92 92
93 public void AddPreCompiledScript(IScript script) 93 public void AddPreCompiledScript(IScript script)
94 { 94 {
95 MainLog.Instance.Verbose("Loading script " + script.getName()); 95 MainLog.Instance.Verbose("Loading script " + script.getName());
96 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. 96 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
97 script.Initialise(scriptInfo); 97 script.Initialise(scriptInfo);
98 scripts.Add(script); 98 scripts.Add(script);
99 } 99 }
100 } 100 }
101 101
102 interface IScriptCompiler 102 interface IScriptCompiler
103 { 103 {
104 Dictionary<string,IScript> compile(string filename); 104 Dictionary<string,IScript> compile(string filename);
105 string FileExt(); 105 string FileExt();
106 } 106 }
107} 107}
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs
index 8f8ac97..fb12c4d 100644
--- a/OpenSim/Region/Environment/StorageManager.cs
+++ b/OpenSim/Region/Environment/StorageManager.cs
@@ -1,60 +1,60 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Framework; 5using OpenSim.Framework;
6using OpenSim.Framework.Communications; 6using OpenSim.Framework.Communications;
7using OpenSim.Framework.Servers; 7using OpenSim.Framework.Servers;
8using OpenSim.Region.Capabilities; 8using OpenSim.Region.Capabilities;
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Interfaces; 10using OpenSim.Region.Interfaces;
11 11
12using System.Reflection; 12using System.Reflection;
13 13
14namespace OpenSim.Region.Environment 14namespace OpenSim.Region.Environment
15{ 15{
16 public class StorageManager 16 public class StorageManager
17 { 17 {
18 private IRegionDataStore m_dataStore; 18 private IRegionDataStore m_dataStore;
19 19
20 public IRegionDataStore DataStore 20 public IRegionDataStore DataStore
21 { 21 {
22 get 22 get
23 { 23 {
24 return m_dataStore; 24 return m_dataStore;
25 } 25 }
26 } 26 }
27 27
28 public StorageManager(IRegionDataStore storage) 28 public StorageManager(IRegionDataStore storage)
29 { 29 {
30 m_dataStore = storage; 30 m_dataStore = storage;
31 } 31 }
32 32
33 public StorageManager(string dllName, string dataStoreFile, string dataStoreDB) 33 public StorageManager(string dllName, string dataStoreFile, string dataStoreDB)
34 { 34 {
35 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 35 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
36 36
37 foreach (Type pluginType in pluginAssembly.GetTypes()) 37 foreach (Type pluginType in pluginAssembly.GetTypes())
38 { 38 {
39 if (pluginType.IsPublic) 39 if (pluginType.IsPublic)
40 { 40 {
41 Type typeInterface = pluginType.GetInterface("IRegionDataStore", true); 41 Type typeInterface = pluginType.GetInterface("IRegionDataStore", true);
42 42
43 if (typeInterface != null) 43 if (typeInterface != null)
44 { 44 {
45 IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 45 IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
46 plug.Initialise(dataStoreFile, dataStoreDB); 46 plug.Initialise(dataStoreFile, dataStoreDB);
47 47
48 m_dataStore = plug; 48 m_dataStore = plug;
49 } 49 }
50 50
51 typeInterface = null; 51 typeInterface = null;
52 } 52 }
53 } 53 }
54 54
55 pluginAssembly = null; 55 pluginAssembly = null;
56 56
57 //TODO: Add checking and warning to make sure it initialised. 57 //TODO: Add checking and warning to make sure it initialised.
58 } 58 }
59 } 59 }
60} 60}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 7e6b1af..28c9b9a 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -1,184 +1,184 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using System.Net; 2using System.Net;
3using System.Timers; 3using System.Timers;
4using System; 4using System;
5using System.Text; 5using System.Text;
6 6
7using libsecondlife; 7using libsecondlife;
8using libsecondlife.Packets; 8using libsecondlife.Packets;
9 9
10using OpenSim.Framework; 10using OpenSim.Framework;
11using OpenSim.Framework.Interfaces; 11using OpenSim.Framework.Interfaces;
12using OpenSim.Framework.Types; 12using OpenSim.Framework.Types;
13using OpenSim.Framework.Data; 13using OpenSim.Framework.Data;
14using OpenSim.Framework.Utilities; 14using OpenSim.Framework.Utilities;
15 15
16namespace SimpleApp 16namespace SimpleApp
17{ 17{
18 public class MyNpcCharacter : IClientAPI 18 public class MyNpcCharacter : IClientAPI
19 { 19 {
20 private uint movementFlag = 0; 20 private uint movementFlag = 0;
21 private short flyState = 0; 21 private short flyState = 0;
22 private LLQuaternion bodyDirection = LLQuaternion.Identity; 22 private LLQuaternion bodyDirection = LLQuaternion.Identity;
23 private short count = 0; 23 private short count = 0;
24 24
25 public event ImprovedInstantMessage OnInstantMessage; 25 public event ImprovedInstantMessage OnInstantMessage;
26 public event ChatFromViewer OnChatFromViewer; 26 public event ChatFromViewer OnChatFromViewer;
27 public event RezObject OnRezObject; 27 public event RezObject OnRezObject;
28 public event ModifyTerrain OnModifyTerrain; 28 public event ModifyTerrain OnModifyTerrain;
29 public event SetAppearance OnSetAppearance; 29 public event SetAppearance OnSetAppearance;
30 public event StartAnim OnStartAnim; 30 public event StartAnim OnStartAnim;
31 public event LinkObjects OnLinkObjects; 31 public event LinkObjects OnLinkObjects;
32 public event RequestMapBlocks OnRequestMapBlocks; 32 public event RequestMapBlocks OnRequestMapBlocks;
33 public event TeleportLocationRequest OnTeleportLocationRequest; 33 public event TeleportLocationRequest OnTeleportLocationRequest;
34 34
35 public event GenericCall4 OnDeRezObject; 35 public event GenericCall4 OnDeRezObject;
36 public event GenericCall OnRegionHandShakeReply; 36 public event GenericCall OnRegionHandShakeReply;
37 public event GenericCall OnRequestWearables; 37 public event GenericCall OnRequestWearables;
38 public event GenericCall2 OnCompleteMovementToRegion; 38 public event GenericCall2 OnCompleteMovementToRegion;
39 public event UpdateAgent OnAgentUpdate; 39 public event UpdateAgent OnAgentUpdate;
40 public event GenericCall OnRequestAvatarsData; 40 public event GenericCall OnRequestAvatarsData;
41 public event AddNewPrim OnAddPrim; 41 public event AddNewPrim OnAddPrim;
42 public event ObjectDuplicate OnObjectDuplicate; 42 public event ObjectDuplicate OnObjectDuplicate;
43 public event UpdateVector OnGrapObject; 43 public event UpdateVector OnGrapObject;
44 public event ObjectSelect OnDeGrapObject; 44 public event ObjectSelect OnDeGrapObject;
45 public event MoveObject OnGrapUpdate; 45 public event MoveObject OnGrapUpdate;
46 46
47 public event UpdateShape OnUpdatePrimShape; 47 public event UpdateShape OnUpdatePrimShape;
48 public event ObjectSelect OnObjectSelect; 48 public event ObjectSelect OnObjectSelect;
49 public event GenericCall7 OnObjectDescription; 49 public event GenericCall7 OnObjectDescription;
50 public event GenericCall7 OnObjectName; 50 public event GenericCall7 OnObjectName;
51 public event UpdatePrimFlags OnUpdatePrimFlags; 51 public event UpdatePrimFlags OnUpdatePrimFlags;
52 public event UpdatePrimTexture OnUpdatePrimTexture; 52 public event UpdatePrimTexture OnUpdatePrimTexture;
53 public event UpdateVector OnUpdatePrimGroupPosition; 53 public event UpdateVector OnUpdatePrimGroupPosition;
54 public event UpdateVector OnUpdatePrimSinglePosition; 54 public event UpdateVector OnUpdatePrimSinglePosition;
55 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 55 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
56 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 56 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
57 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; 57 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
58 public event UpdateVector OnUpdatePrimScale; 58 public event UpdateVector OnUpdatePrimScale;
59 public event StatusChange OnChildAgentStatus; 59 public event StatusChange OnChildAgentStatus;
60 public event GenericCall2 OnStopMovement; 60 public event GenericCall2 OnStopMovement;
61 public event NewAvatar OnNewAvatar; 61 public event NewAvatar OnNewAvatar;
62 public event GenericCall6 OnRemoveAvatar; 62 public event GenericCall6 OnRemoveAvatar;
63 63
64 public event UUIDNameRequest OnNameFromUUIDRequest; 64 public event UUIDNameRequest OnNameFromUUIDRequest;
65 65
66 public event ParcelPropertiesRequest OnParcelPropertiesRequest; 66 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
67 public event ParcelDivideRequest OnParcelDivideRequest; 67 public event ParcelDivideRequest OnParcelDivideRequest;
68 public event ParcelJoinRequest OnParcelJoinRequest; 68 public event ParcelJoinRequest OnParcelJoinRequest;
69 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; 69 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
70 70
71 public event ParcelSelectObjects OnParcelSelectObjects; 71 public event ParcelSelectObjects OnParcelSelectObjects;
72 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; 72 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
73 public event ObjectDeselect OnObjectDeselect; 73 public event ObjectDeselect OnObjectDeselect;
74 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 74 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
75 75
76 private LLUUID myID = LLUUID.Random(); 76 private LLUUID myID = LLUUID.Random();
77 public MyNpcCharacter() 77 public MyNpcCharacter()
78 { 78 {
79 79
80 } 80 }
81 81
82 public virtual LLVector3 StartPos 82 public virtual LLVector3 StartPos
83 { 83 {
84 get { return new LLVector3(128, 100, 2); } 84 get { return new LLVector3(128, 100, 2); }
85 set { } 85 set { }
86 } 86 }
87 87
88 public virtual LLUUID AgentId 88 public virtual LLUUID AgentId
89 { 89 {
90 get { return myID; } 90 get { return myID; }
91 } 91 }
92 92
93 public virtual string FirstName 93 public virtual string FirstName
94 { 94 {
95 get { return "Annoying"; } 95 get { return "Annoying"; }
96 } 96 }
97 97
98 public virtual string LastName 98 public virtual string LastName
99 { 99 {
100 get { return "NPC"; } 100 get { return "NPC"; }
101 } 101 }
102 102
103 public virtual void OutPacket(Packet newPack) { } 103 public virtual void OutPacket(Packet newPack) { }
104 public virtual void SendWearables(AvatarWearable[] wearables) { } 104 public virtual void SendWearables(AvatarWearable[] wearables) { }
105 public virtual void SendStartPingCheck(byte seq) { } 105 public virtual void SendStartPingCheck(byte seq) { }
106 public virtual void SendKillObject(ulong regionHandle, uint avatarLocalID) { } 106 public virtual void SendKillObject(ulong regionHandle, uint avatarLocalID) { }
107 public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { } 107 public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { }
108 public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } 108 public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { }
109 public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } 109 public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { }
110 public virtual void SendInstantMessage(string message, LLUUID target, string fromName) { } 110 public virtual void SendInstantMessage(string message, LLUUID target, string fromName) { }
111 public virtual void SendLayerData(float[] map) { } 111 public virtual void SendLayerData(float[] map) { }
112 public virtual void SendLayerData(int px, int py, float[] map) { } 112 public virtual void SendLayerData(int px, int py, float[] map) { }
113 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { } 113 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { }
114 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { } 114 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { }
115 public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); } 115 public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); }
116 public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint) { } 116 public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint) { }
117 public virtual void SendMapBlock(List<MapBlockData> mapBlocks) { } 117 public virtual void SendMapBlock(List<MapBlockData> mapBlocks) { }
118 public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { } 118 public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { }
119 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags) { } 119 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags) { }
120 public virtual void SendTeleportCancel() { } 120 public virtual void SendTeleportCancel() { }
121 public virtual void SendTeleportLocationStart() { } 121 public virtual void SendTeleportLocationStart() { }
122 public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } 122 public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { }
123 123
124 public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { } 124 public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { }
125 public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { } 125 public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { }
126 126
127 public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { } 127 public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { }
128 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) { } 128 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) { }
129 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) { } 129 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) { }
130 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } 130 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { }
131 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { } 131 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { }
132 public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { } 132 public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { }
133 133
134 public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) { } 134 public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) { }
135 public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { } 135 public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { }
136 public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { } 136 public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { }
137 137
138 public virtual void SendRegionHandshake(RegionInfo regionInfo) 138 public virtual void SendRegionHandshake(RegionInfo regionInfo)
139 { 139 {
140 this.OnRegionHandShakeReply(this); 140 this.OnRegionHandShakeReply(this);
141 this.OnCompleteMovementToRegion(); 141 this.OnCompleteMovementToRegion();
142 this.StartMovement(); 142 this.StartMovement();
143 } 143 }
144 144
145 public void StartMovement() 145 public void StartMovement()
146 { 146 {
147 Timer timer = new Timer(); 147 Timer timer = new Timer();
148 timer.Enabled = true; 148 timer.Enabled = true;
149 timer.Interval = 500; 149 timer.Interval = 500;
150 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat); 150 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
151 } 151 }
152 152
153 public void Heartbeat(object sender, EventArgs e) 153 public void Heartbeat(object sender, EventArgs e)
154 { 154 {
155 Encoding enc = Encoding.ASCII; 155 Encoding enc = Encoding.ASCII;
156 156
157 this.OnAgentUpdate(this, movementFlag, bodyDirection); 157 this.OnAgentUpdate(this, movementFlag, bodyDirection);
158 158
159 if (this.flyState == 0) 159 if (this.flyState == 0)
160 { 160 {
161 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG; 161 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG;
162 flyState = 1; 162 flyState = 1;
163 } 163 }
164 else if (this.flyState == 1) 164 else if (this.flyState == 1)
165 { 165 {
166 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS; 166 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS;
167 flyState = 2; 167 flyState = 2;
168 } 168 }
169 else 169 else
170 { 170 {
171 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY; 171 movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY;
172 flyState = 0; 172 flyState = 0;
173 } 173 }
174 174
175 if (count >= 40) 175 if (count >= 40)
176 { 176 {
177 this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId); 177 this.OnChatFromViewer(enc.GetBytes("Kind of quiet around here, isn't it! \0"), 2, new LLVector3(128, 128, 26), this.FirstName + " " + this.LastName, this.AgentId);
178 count = -1; 178 count = -1;
179 } 179 }
180 180
181 count++; 181 count++;
182 } 182 }
183 } 183 }
184} 184}
diff --git a/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs b/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
index aab52cc..f5c6a0f 100644
--- a/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
@@ -1,40 +1,40 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Region.Environment.Scenes; 4using OpenSim.Region.Environment.Scenes;
5using libsecondlife; 5using libsecondlife;
6using OpenSim.Framework.Types; 6using OpenSim.Framework.Types;
7using System.Timers; 7using System.Timers;
8using System.Diagnostics; 8using System.Diagnostics;
9 9
10namespace SimpleApp 10namespace SimpleApp
11{ 11{
12 public class MySceneObject : SceneObject 12 public class MySceneObject : SceneObject
13 { 13 {
14 private PerformanceCounter m_counter; 14 private PerformanceCounter m_counter;
15 15
16 public MySceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) 16 public MySceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
17 : base(world, eventManager, ownerID, localID, pos, shape ) 17 : base(world, eventManager, ownerID, localID, pos, shape )
18 { 18 {
19 String objectName = "Processor"; 19 String objectName = "Processor";
20 String counterName = "% Processor Time"; 20 String counterName = "% Processor Time";
21 String instanceName = "_Total"; 21 String instanceName = "_Total";
22 22
23 m_counter = new PerformanceCounter(objectName, counterName, instanceName); 23 m_counter = new PerformanceCounter(objectName, counterName, instanceName);
24 24
25 Timer timer = new Timer(); 25 Timer timer = new Timer();
26 timer.Enabled = true; 26 timer.Enabled = true;
27 timer.Interval = 100; 27 timer.Interval = 100;
28 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat); 28 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
29 29
30 } 30 }
31 31
32 public void Heartbeat(object sender, EventArgs e) 32 public void Heartbeat(object sender, EventArgs e)
33 { 33 {
34 float cpu = m_counter.NextValue() / 40f; 34 float cpu = m_counter.NextValue() / 40f;
35 LLVector3 size = new LLVector3(cpu, cpu, cpu); 35 LLVector3 size = new LLVector3(cpu, cpu, cpu);
36 rootPrimitive.ResizeGoup( size ); 36 rootPrimitive.ResizeGoup( size );
37 update(); 37 update();
38 } 38 }
39 } 39 }
40} 40}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index 29b255b..4fe3c7a 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -1,97 +1,97 @@
1using System.Collections.Generic; 1using System.Collections.Generic;
2using libsecondlife; 2using libsecondlife;
3using OpenSim.Framework; 3using OpenSim.Framework;
4using OpenSim.Framework.Communications; 4using OpenSim.Framework.Communications;
5using OpenSim.Framework.Interfaces; 5using OpenSim.Framework.Interfaces;
6using OpenSim.Framework.Servers; 6using OpenSim.Framework.Servers;
7using OpenSim.Framework.Types; 7using OpenSim.Framework.Types;
8using OpenSim.Region.Caches; 8using OpenSim.Region.Caches;
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Terrain; 10using OpenSim.Region.Terrain;
11using OpenSim.Region.Environment; 11using OpenSim.Region.Environment;
12 12
13using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; 13using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
14 14
15namespace SimpleApp 15namespace SimpleApp
16{ 16{
17 public class MyWorld : Scene 17 public class MyWorld : Scene
18 { 18 {
19 private List<ScenePresence> m_avatars; 19 private List<ScenePresence> m_avatars;
20 20
21 public MyWorld( RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer) 21 public MyWorld( RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer)
22 : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer) 22 : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer)
23 { 23 {
24 m_avatars = new List<Avatar>(); 24 m_avatars = new List<Avatar>();
25 } 25 }
26 26
27 public override void LoadWorldMap() 27 public override void LoadWorldMap()
28 { 28 {
29 float[] map = new float[65536]; 29 float[] map = new float[65536];
30 30
31 for (int i = 0; i < 65536; i++) 31 for (int i = 0; i < 65536; i++)
32 { 32 {
33 int x = i % 256; 33 int x = i % 256;
34 int y = i / 256; 34 int y = i / 256;
35 35
36 map[i] = 25f; 36 map[i] = 25f;
37 } 37 }
38 38
39 this.Terrain.setHeights1D(map); 39 this.Terrain.setHeights1D(map);
40 this.CreateTerrainTexture(); 40 this.CreateTerrainTexture();
41 } 41 }
42 42
43 #region IWorld Members 43 #region IWorld Members
44 44
45 override public void AddNewClient(IClientAPI client, bool child) 45 override public void AddNewClient(IClientAPI client, bool child)
46 { 46 {
47 LLVector3 pos = new LLVector3(128, 128, 128); 47 LLVector3 pos = new LLVector3(128, 128, 128);
48 48
49 client.OnRegionHandShakeReply += SendLayerData; 49 client.OnRegionHandShakeReply += SendLayerData;
50 /*client.OnChatFromViewer += 50 /*client.OnChatFromViewer +=
51 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 51 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
52 { 52 {
53 // Echo it (so you know what you typed) 53 // Echo it (so you know what you typed)
54 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); 54 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
55 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); 55 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
56 }; 56 };
57 */ 57 */
58 client.OnChatFromViewer += this.SimChat; 58 client.OnChatFromViewer += this.SimChat;
59 client.OnAddPrim += AddNewPrim; 59 client.OnAddPrim += AddNewPrim;
60 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; 60 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
61 client.OnRequestMapBlocks += this.RequestMapBlocks; 61 client.OnRequestMapBlocks += this.RequestMapBlocks;
62 client.OnTeleportLocationRequest += this.RequestTeleportLocation; 62 client.OnTeleportLocationRequest += this.RequestTeleportLocation;
63 client.OnGrapUpdate += this.MoveObject; 63 client.OnGrapUpdate += this.MoveObject;
64 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; 64 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
65 65
66 client.OnCompleteMovementToRegion += delegate() 66 client.OnCompleteMovementToRegion += delegate()
67 { 67 {
68 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero ); 68 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
69 }; 69 };
70 70
71 client.SendRegionHandshake(m_regInfo); 71 client.SendRegionHandshake(m_regInfo);
72 72
73 ScenePresence avatar = CreateAndAddScenePresence(client); 73 ScenePresence avatar = CreateAndAddScenePresence(client);
74 avatar.Pos = new LLVector3(128, 128, 26); 74 avatar.Pos = new LLVector3(128, 128, 26);
75 } 75 }
76 76
77 public override void Update() 77 public override void Update()
78 { 78 {
79 foreach (LLUUID UUID in Entities.Keys) 79 foreach (LLUUID UUID in Entities.Keys)
80 { 80 {
81 Entities[UUID].updateMovement(); 81 Entities[UUID].updateMovement();
82 } 82 }
83 83
84 lock (this.m_syncRoot) 84 lock (this.m_syncRoot)
85 { 85 {
86 this.phyScene.Simulate(timeStep); 86 this.phyScene.Simulate(timeStep);
87 } 87 }
88 88
89 foreach (LLUUID UUID in Entities.Keys) 89 foreach (LLUUID UUID in Entities.Keys)
90 { 90 {
91 Entities[UUID].update(); 91 Entities[UUID].update();
92 } 92 }
93 } 93 }
94 94
95 #endregion 95 #endregion
96 } 96 }
97} 97}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index c3edf0c..f82bdcb 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -1,126 +1,126 @@
1using System; 1using System;
2using System.Net; 2using System.Net;
3using libsecondlife; 3using libsecondlife;
4using OpenSim.Assets; 4using OpenSim.Assets;
5using OpenSim.Framework; 5using OpenSim.Framework;
6using OpenSim.Framework.Console; 6using OpenSim.Framework.Console;
7using OpenSim.Framework.Interfaces; 7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Servers; 8using OpenSim.Framework.Servers;
9using OpenSim.Framework.Types; 9using OpenSim.Framework.Types;
10using OpenSim.Physics.Manager; 10using OpenSim.Physics.Manager;
11using OpenSim.Region.Caches; 11using OpenSim.Region.Caches;
12using OpenSim.Region.Capabilities; 12using OpenSim.Region.Capabilities;
13using OpenSim.Region.ClientStack; 13using OpenSim.Region.ClientStack;
14using OpenSim.Region.Communications.Local; 14using OpenSim.Region.Communications.Local;
15using OpenSim.Region.GridInterfaces.Local; 15using OpenSim.Region.GridInterfaces.Local;
16using System.Timers; 16using System.Timers;
17using OpenSim.Region.Environment.Scenes; 17using OpenSim.Region.Environment.Scenes;
18using OpenSim.Framework.Data; 18using OpenSim.Framework.Data;
19 19
20namespace SimpleApp 20namespace SimpleApp
21{ 21{
22 class Program : conscmd_callback 22 class Program : conscmd_callback
23 { 23 {
24 private LogBase m_log; 24 private LogBase m_log;
25 AuthenticateSessionsBase m_circuitManager; 25 AuthenticateSessionsBase m_circuitManager;
26 uint m_localId; 26 uint m_localId;
27 public MyWorld world; 27 public MyWorld world;
28 private SceneObject m_sceneObject; 28 private SceneObject m_sceneObject;
29 public MyNpcCharacter m_character; 29 public MyNpcCharacter m_character;
30 30
31 private void Run() 31 private void Run()
32 { 32 {
33 m_log = new LogBase(null, "SimpleApp", this, false); 33 m_log = new LogBase(null, "SimpleApp", this, false);
34 MainLog.Instance = m_log; 34 MainLog.Instance = m_log;
35 35
36 // CheckSumServer checksumServer = new CheckSumServer(12036); 36 // CheckSumServer checksumServer = new CheckSumServer(12036);
37 // checksumServer.ServerListener(); 37 // checksumServer.ServerListener();
38 38
39 IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000); 39 IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
40 40
41 m_circuitManager = new AuthenticateSessionsBase(); 41 m_circuitManager = new AuthenticateSessionsBase();
42 42
43 InventoryCache inventoryCache = new InventoryCache(); 43 InventoryCache inventoryCache = new InventoryCache();
44 44
45 LocalAssetServer assetServer = new LocalAssetServer(); 45 LocalAssetServer assetServer = new LocalAssetServer();
46 assetServer.SetServerInfo("http://127.0.0.1:8003/", ""); 46 assetServer.SetServerInfo("http://127.0.0.1:8003/", "");
47 47
48 AssetCache assetCache = new AssetCache(assetServer); 48 AssetCache assetCache = new AssetCache(assetServer);
49 49
50 ScenePresence.LoadTextureFile("avatar-texture.dat"); 50 ScenePresence.LoadTextureFile("avatar-texture.dat");
51 ScenePresence.PhysicsEngineFlying = true; 51 ScenePresence.PhysicsEngineFlying = true;
52 52
53 PhysicsManager physManager = new PhysicsManager(); 53 PhysicsManager physManager = new PhysicsManager();
54 physManager.LoadPlugins(); 54 physManager.LoadPlugins();
55 55
56 UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager); 56 UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
57 PacketServer packetServer = new PacketServer(udpServer); 57 PacketServer packetServer = new PacketServer(udpServer);
58 58
59 ClientView.TerrainManager = new TerrainManager(new SecondLife()); 59 ClientView.TerrainManager = new TerrainManager(new SecondLife());
60 BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port); 60 BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
61 61
62 NetworkServersInfo serverInfo = new NetworkServersInfo(); 62 NetworkServersInfo serverInfo = new NetworkServersInfo();
63 CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer); 63 CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
64 64
65 RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1"); 65 RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1");
66 66
67 OpenSim.Region.Environment.StorageManager storeMan = new OpenSim.Region.Environment.StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp"); 67 OpenSim.Region.Environment.StorageManager storeMan = new OpenSim.Region.Environment.StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp");
68 68
69 world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer); 69 world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
70 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; 70 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
71 71
72 world.LoadWorldMap(); 72 world.LoadWorldMap();
73 world.PhysScene.SetTerrain(world.Terrain.getHeights1D()); 73 world.PhysScene.SetTerrain(world.Terrain.getHeights1D());
74 world.performParcelPrimCountUpdate(); 74 world.performParcelPrimCountUpdate();
75 75
76 udpServer.LocalWorld = world; 76 udpServer.LocalWorld = world;
77 77
78 httpServer.Start(); 78 httpServer.Start();
79 udpServer.ServerListener(); 79 udpServer.ServerListener();
80 80
81 UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test"); 81 UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
82 if (masterAvatar != null) 82 if (masterAvatar != null)
83 { 83 {
84 world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; 84 world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
85 world.ParcelManager.NoParcelDataFromStorage(); 85 world.ParcelManager.NoParcelDataFromStorage();
86 } 86 }
87 87
88 world.StartTimer(); 88 world.StartTimer();
89 89
90 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); 90 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
91 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); 91 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
92 LLVector3 pos = new LLVector3(138, 129, 27); 92 LLVector3 pos = new LLVector3(138, 129, 27);
93 93
94 m_sceneObject = new MySceneObject(world, world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape); 94 m_sceneObject = new MySceneObject(world, world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape);
95 world.AddEntity(m_sceneObject); 95 world.AddEntity(m_sceneObject);
96 96
97 m_character = new MyNpcCharacter(); 97 m_character = new MyNpcCharacter();
98 world.AddNewClient(m_character, false); 98 world.AddNewClient(m_character, false);
99 99
100 m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); 100 m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
101 m_log.ReadLine(); 101 m_log.ReadLine();
102 102
103 } 103 }
104 104
105 #region conscmd_callback Members 105 #region conscmd_callback Members
106 106
107 public void RunCmd(string cmd, string[] cmdparams) 107 public void RunCmd(string cmd, string[] cmdparams)
108 { 108 {
109 throw new Exception("The method or operation is not implemented."); 109 throw new Exception("The method or operation is not implemented.");
110 } 110 }
111 111
112 public void Show(string ShowWhat) 112 public void Show(string ShowWhat)
113 { 113 {
114 throw new Exception("The method or operation is not implemented."); 114 throw new Exception("The method or operation is not implemented.");
115 } 115 }
116 116
117 #endregion 117 #endregion
118 118
119 static void Main(string[] args) 119 static void Main(string[] args)
120 { 120 {
121 Program app = new Program(); 121 Program app = new Program();
122 122
123 app.Run(); 123 app.Run();
124 } 124 }
125 } 125 }
126} 126}
diff --git a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
index 3b0de8a..2250613 100644
--- a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs
@@ -1,31 +1,31 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.InteropServices; 2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following 3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information 4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly. 5// associated with an assembly.
6[assembly: AssemblyTitle("SimpleApp")] 6[assembly: AssemblyTitle("SimpleApp")]
7[assembly: AssemblyDescription("")] 7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")] 8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("Playahead AB")] 9[assembly: AssemblyCompany("Playahead AB")]
10[assembly: AssemblyProduct("SimpleApp")] 10[assembly: AssemblyProduct("SimpleApp")]
11[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] 11[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")]
12[assembly: AssemblyTrademark("")] 12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")] 13[assembly: AssemblyCulture("")]
14 14
15// Setting ComVisible to false makes the types in this assembly not visible 15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from 16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type. 17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)] 18[assembly: ComVisible(false)]
19 19
20// The following GUID is for the ID of the typelib if this project is exposed to COM 20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")] 21[assembly: Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")]
22 22
23// Version information for an assembly consists of the following four values: 23// Version information for an assembly consists of the following four values:
24// 24//
25// Major Version 25// Major Version
26// Minor Version 26// Minor Version
27// Build Number 27// Build Number
28// Revision 28// Revision
29// 29//
30[assembly: AssemblyVersion("1.0.0.0")] 30[assembly: AssemblyVersion("1.0.0.0")]
31[assembly: AssemblyFileVersion("1.0.0.0")] 31[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
index b5fc1ef..61adf80 100644
--- a/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
+++ b/OpenSim/Region/GridInterfaces/Local/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("LocalGridServers")] 36[assembly: AssemblyTitle("LocalGridServers")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("LocalGridServers")] 40[assembly: AssemblyProduct("LocalGridServers")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
index 1023820..f3d7a2c 100644
--- a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
+++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
@@ -1,311 +1,311 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Threading; 30using System.Threading;
31using Db4objects.Db4o; 31using Db4objects.Db4o;
32using Db4objects.Db4o.Query; 32using Db4objects.Db4o.Query;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38
39namespace OpenSim.Region.GridInterfaces.Local 39namespace OpenSim.Region.GridInterfaces.Local
40{ 40{
41 public class LocalAssetPlugin : IAssetPlugin 41 public class LocalAssetPlugin : IAssetPlugin
42 { 42 {
43 public LocalAssetPlugin() 43 public LocalAssetPlugin()
44 { 44 {
45 45
46 } 46 }
47 47
48 public IAssetServer GetAssetServer() 48 public IAssetServer GetAssetServer()
49 { 49 {
50 return (new LocalAssetServer()); 50 return (new LocalAssetServer());
51 } 51 }
52 } 52 }
53 53
54 public class LocalAssetServer : IAssetServer 54 public class LocalAssetServer : IAssetServer
55 { 55 {
56 private IAssetReceiver _receiver; 56 private IAssetReceiver _receiver;
57 private BlockingQueue<ARequest> _assetRequests; 57 private BlockingQueue<ARequest> _assetRequests;
58 private IObjectContainer db; 58 private IObjectContainer db;
59 private Thread _localAssetServerThread; 59 private Thread _localAssetServerThread;
60 60
61 public LocalAssetServer() 61 public LocalAssetServer()
62 { 62 {
63 bool yapfile; 63 bool yapfile;
64 this._assetRequests = new BlockingQueue<ARequest>(); 64 this._assetRequests = new BlockingQueue<ARequest>();
65 yapfile = File.Exists("regionassets.yap"); 65 yapfile = File.Exists("regionassets.yap");
66 66
67 MainLog.Instance.Verbose( "Local Asset Server class created"); 67 MainLog.Instance.Verbose( "Local Asset Server class created");
68 try 68 try
69 { 69 {
70 db = Db4oFactory.OpenFile("regionassets.yap"); 70 db = Db4oFactory.OpenFile("regionassets.yap");
71 MainLog.Instance.Verbose( "Db4 Asset database creation"); 71 MainLog.Instance.Verbose( "Db4 Asset database creation");
72 } 72 }
73 catch (Exception e) 73 catch (Exception e)
74 { 74 {
75 db.Close(); 75 db.Close();
76 MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured"); 76 MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured");
77 MainLog.Instance.Warn(e.ToString()); 77 MainLog.Instance.Warn(e.ToString());
78 } 78 }
79 if (!yapfile) 79 if (!yapfile)
80 { 80 {
81 this.SetUpAssetDatabase(); 81 this.SetUpAssetDatabase();
82 } 82 }
83 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); 83 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
84 this._localAssetServerThread.IsBackground = true; 84 this._localAssetServerThread.IsBackground = true;
85 this._localAssetServerThread.Start(); 85 this._localAssetServerThread.Start();
86 86
87 } 87 }
88 88
89 public void SetReceiver(IAssetReceiver receiver) 89 public void SetReceiver(IAssetReceiver receiver)
90 { 90 {
91 this._receiver = receiver; 91 this._receiver = receiver;
92 } 92 }
93 93
94 public void RequestAsset(LLUUID assetID, bool isTexture) 94 public void RequestAsset(LLUUID assetID, bool isTexture)
95 { 95 {
96 ARequest req = new ARequest(); 96 ARequest req = new ARequest();
97 req.AssetID = assetID; 97 req.AssetID = assetID;
98 req.IsTexture = isTexture; 98 req.IsTexture = isTexture;
99 this._assetRequests.Enqueue(req); 99 this._assetRequests.Enqueue(req);
100 } 100 }
101 101
102 public void UpdateAsset(AssetBase asset) 102 public void UpdateAsset(AssetBase asset)
103 { 103 {
104 104
105 } 105 }
106 106
107 public void UploadNewAsset(AssetBase asset) 107 public void UploadNewAsset(AssetBase asset)
108 { 108 {
109 AssetStorage store = new AssetStorage(); 109 AssetStorage store = new AssetStorage();
110 store.Data = asset.Data; 110 store.Data = asset.Data;
111 store.Name = asset.Name; 111 store.Name = asset.Name;
112 store.UUID = asset.FullID; 112 store.UUID = asset.FullID;
113 db.Set(store); 113 db.Set(store);
114 db.Commit(); 114 db.Commit();
115 } 115 }
116 116
117 public void SetServerInfo(string ServerUrl, string ServerKey) 117 public void SetServerInfo(string ServerUrl, string ServerKey)
118 { 118 {
119 119
120 } 120 }
121 public void Close() 121 public void Close()
122 { 122 {
123 if (db != null) 123 if (db != null)
124 { 124 {
125 MainLog.Instance.Verbose( "Closing local asset server database"); 125 MainLog.Instance.Verbose( "Closing local asset server database");
126 db.Close(); 126 db.Close();
127 } 127 }
128 } 128 }
129 129
130 private void RunRequests() 130 private void RunRequests()
131 { 131 {
132 while (true) 132 while (true)
133 { 133 {
134 byte[] idata = null; 134 byte[] idata = null;
135 bool found = false; 135 bool found = false;
136 AssetStorage foundAsset = null; 136 AssetStorage foundAsset = null;
137 ARequest req = this._assetRequests.Dequeue(); 137 ARequest req = this._assetRequests.Dequeue();
138 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); 138 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
139 if (result.Count > 0) 139 if (result.Count > 0)
140 { 140 {
141 foundAsset = (AssetStorage)result.Next(); 141 foundAsset = (AssetStorage)result.Next();
142 found = true; 142 found = true;
143 } 143 }
144 144
145 AssetBase asset = new AssetBase(); 145 AssetBase asset = new AssetBase();
146 if (found) 146 if (found)
147 { 147 {
148 asset.FullID = foundAsset.UUID; 148 asset.FullID = foundAsset.UUID;
149 asset.Type = foundAsset.Type; 149 asset.Type = foundAsset.Type;
150 asset.InvType = foundAsset.Type; 150 asset.InvType = foundAsset.Type;
151 asset.Name = foundAsset.Name; 151 asset.Name = foundAsset.Name;
152 idata = foundAsset.Data; 152 idata = foundAsset.Data;
153 } 153 }
154 else 154 else
155 { 155 {
156 asset.FullID = LLUUID.Zero; 156 asset.FullID = LLUUID.Zero;
157 } 157 }
158 asset.Data = idata; 158 asset.Data = idata;
159 _receiver.AssetReceived(asset, req.IsTexture); 159 _receiver.AssetReceived(asset, req.IsTexture);
160 } 160 }
161 161
162 } 162 }
163 163
164 private void SetUpAssetDatabase() 164 private void SetUpAssetDatabase()
165 { 165 {
166 try 166 try
167 { 167 {
168 168
169 MainLog.Instance.Verbose( "Setting up asset database"); 169 MainLog.Instance.Verbose( "Setting up asset database");
170 170
171 AssetBase Image = new AssetBase(); 171 AssetBase Image = new AssetBase();
172 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); 172 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
173 Image.Name = "Bricks"; 173 Image.Name = "Bricks";
174 this.LoadAsset(Image, true, "bricks.jp2"); 174 this.LoadAsset(Image, true, "bricks.jp2");
175 AssetStorage store = new AssetStorage(); 175 AssetStorage store = new AssetStorage();
176 store.Data = Image.Data; 176 store.Data = Image.Data;
177 store.Name = Image.Name; 177 store.Name = Image.Name;
178 store.UUID = Image.FullID; 178 store.UUID = Image.FullID;
179 db.Set(store); 179 db.Set(store);
180 db.Commit(); 180 db.Commit();
181 181
182 Image = new AssetBase(); 182 Image = new AssetBase();
183 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); 183 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
184 Image.Name = "Plywood"; 184 Image.Name = "Plywood";
185 this.LoadAsset(Image, true, "plywood.jp2"); 185 this.LoadAsset(Image, true, "plywood.jp2");
186 store = new AssetStorage(); 186 store = new AssetStorage();
187 store.Data = Image.Data; 187 store.Data = Image.Data;
188 store.Name = Image.Name; 188 store.Name = Image.Name;
189 store.UUID = Image.FullID; 189 store.UUID = Image.FullID;
190 db.Set(store); 190 db.Set(store);
191 db.Commit(); 191 db.Commit();
192 192
193 Image = new AssetBase(); 193 Image = new AssetBase();
194 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); 194 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
195 Image.Name = "Rocks"; 195 Image.Name = "Rocks";
196 this.LoadAsset(Image, true, "rocks.jp2"); 196 this.LoadAsset(Image, true, "rocks.jp2");
197 store = new AssetStorage(); 197 store = new AssetStorage();
198 store.Data = Image.Data; 198 store.Data = Image.Data;
199 store.Name = Image.Name; 199 store.Name = Image.Name;
200 store.UUID = Image.FullID; 200 store.UUID = Image.FullID;
201 db.Set(store); 201 db.Set(store);
202 db.Commit(); 202 db.Commit();
203 203
204 Image = new AssetBase(); 204 Image = new AssetBase();
205 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); 205 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
206 Image.Name = "Granite"; 206 Image.Name = "Granite";
207 this.LoadAsset(Image, true, "granite.jp2"); 207 this.LoadAsset(Image, true, "granite.jp2");
208 store = new AssetStorage(); 208 store = new AssetStorage();
209 store.Data = Image.Data; 209 store.Data = Image.Data;
210 store.Name = Image.Name; 210 store.Name = Image.Name;
211 store.UUID = Image.FullID; 211 store.UUID = Image.FullID;
212 db.Set(store); 212 db.Set(store);
213 db.Commit(); 213 db.Commit();
214 214
215 Image = new AssetBase(); 215 Image = new AssetBase();
216 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); 216 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
217 Image.Name = "Hardwood"; 217 Image.Name = "Hardwood";
218 this.LoadAsset(Image, true, "hardwood.jp2"); 218 this.LoadAsset(Image, true, "hardwood.jp2");
219 store = new AssetStorage(); 219 store = new AssetStorage();
220 store.Data = Image.Data; 220 store.Data = Image.Data;
221 store.Name = Image.Name; 221 store.Name = Image.Name;
222 store.UUID = Image.FullID; 222 store.UUID = Image.FullID;
223 db.Set(store); 223 db.Set(store);
224 db.Commit(); 224 db.Commit();
225 225
226 Image = new AssetBase(); 226 Image = new AssetBase();
227 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); 227 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
228 Image.Name = "Prim Base Texture"; 228 Image.Name = "Prim Base Texture";
229 this.LoadAsset(Image, true, "plywood.jp2"); 229 this.LoadAsset(Image, true, "plywood.jp2");
230 store = new AssetStorage(); 230 store = new AssetStorage();
231 store.Data = Image.Data; 231 store.Data = Image.Data;
232 store.Name = Image.Name; 232 store.Name = Image.Name;
233 store.UUID = Image.FullID; 233 store.UUID = Image.FullID;
234 db.Set(store); 234 db.Set(store);
235 db.Commit(); 235 db.Commit();
236 236
237 Image = new AssetBase(); 237 Image = new AssetBase();
238 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); 238 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
239 Image.Name = "Map Base Texture"; 239 Image.Name = "Map Base Texture";
240 this.LoadAsset(Image, true, "map_base.jp2"); 240 this.LoadAsset(Image, true, "map_base.jp2");
241 store = new AssetStorage(); 241 store = new AssetStorage();
242 store.Data = Image.Data; 242 store.Data = Image.Data;
243 store.Name = Image.Name; 243 store.Name = Image.Name;
244 store.UUID = Image.FullID; 244 store.UUID = Image.FullID;
245 db.Set(store); 245 db.Set(store);
246 db.Commit(); 246 db.Commit();
247 247
248 Image = new AssetBase(); 248 Image = new AssetBase();
249 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); 249 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
250 Image.Name = "Map Texture"; 250 Image.Name = "Map Texture";
251 this.LoadAsset(Image, true, "map1.jp2"); 251 this.LoadAsset(Image, true, "map1.jp2");
252 store = new AssetStorage(); 252 store = new AssetStorage();
253 store.Data = Image.Data; 253 store.Data = Image.Data;
254 store.Name = Image.Name; 254 store.Name = Image.Name;
255 store.UUID = Image.FullID; 255 store.UUID = Image.FullID;
256 db.Set(store); 256 db.Set(store);
257 db.Commit(); 257 db.Commit();
258 258
259 Image = new AssetBase(); 259 Image = new AssetBase();
260 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); 260 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
261 Image.Name = "Shape"; 261 Image.Name = "Shape";
262 this.LoadAsset(Image, false, "base_shape.dat"); 262 this.LoadAsset(Image, false, "base_shape.dat");
263 store = new AssetStorage(); 263 store = new AssetStorage();
264 store.Data = Image.Data; 264 store.Data = Image.Data;
265 store.Name = Image.Name; 265 store.Name = Image.Name;
266 store.UUID = Image.FullID; 266 store.UUID = Image.FullID;
267 db.Set(store); 267 db.Set(store);
268 db.Commit(); 268 db.Commit();
269 } 269 }
270 catch (Exception e) 270 catch (Exception e)
271 { 271 {
272 Console.WriteLine("exception loading default assets into database"); 272 Console.WriteLine("exception loading default assets into database");
273 Console.WriteLine(e.Message); 273 Console.WriteLine(e.Message);
274 } 274 }
275 275
276 } 276 }
277 277
278 private void LoadAsset(AssetBase info, bool image, string filename) 278 private void LoadAsset(AssetBase info, bool image, string filename)
279 { 279 {
280 //should request Asset from storage manager 280 //should request Asset from storage manager
281 //but for now read from file 281 //but for now read from file
282 282
283 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; 283 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
284 string fileName = Path.Combine(dataPath, filename); 284 string fileName = Path.Combine(dataPath, filename);
285 FileInfo fInfo = new FileInfo(fileName); 285 FileInfo fInfo = new FileInfo(fileName);
286 long numBytes = fInfo.Length; 286 long numBytes = fInfo.Length;
287 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); 287 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
288 byte[] idata = new byte[numBytes]; 288 byte[] idata = new byte[numBytes];
289 BinaryReader br = new BinaryReader(fStream); 289 BinaryReader br = new BinaryReader(fStream);
290 idata = br.ReadBytes((int)numBytes); 290 idata = br.ReadBytes((int)numBytes);
291 br.Close(); 291 br.Close();
292 fStream.Close(); 292 fStream.Close();
293 info.Data = idata; 293 info.Data = idata;
294 //info.loaded=true; 294 //info.loaded=true;
295 } 295 }
296 } 296 }
297 public class AssetUUIDQuery : Predicate 297 public class AssetUUIDQuery : Predicate
298 { 298 {
299 private LLUUID _findID; 299 private LLUUID _findID;
300 300
301 public AssetUUIDQuery(LLUUID find) 301 public AssetUUIDQuery(LLUUID find)
302 { 302 {
303 _findID = find; 303 _findID = find;
304 } 304 }
305 public bool Match(AssetStorage asset) 305 public bool Match(AssetStorage asset)
306 { 306 {
307 return (asset.UUID == _findID); 307 return (asset.UUID == _findID);
308 } 308 }
309 } 309 }
310 310
311} 311}
diff --git a/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
index 1e15c5e..a658f2f 100644
--- a/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
+++ b/OpenSim/Region/GridInterfaces/Remote/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("RemoteGridServers")] 36[assembly: AssemblyTitle("RemoteGridServers")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RemoteGridServers")] 40[assembly: AssemblyProduct("RemoteGridServers")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
index 8643736..f81bb8d 100644
--- a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
+++ b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
@@ -1,133 +1,133 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.IO; 28using System.IO;
29using System.Net; 29using System.Net;
30using System.Text; 30using System.Text;
31using System.Threading; 31using System.Threading;
32using libsecondlife; 32using libsecondlife;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37 37
38namespace OpenSim.Region.GridInterfaces.Remote 38namespace OpenSim.Region.GridInterfaces.Remote
39{ 39{
40 public class RemoteAssetServer : IAssetServer 40 public class RemoteAssetServer : IAssetServer
41 { 41 {
42 private IAssetReceiver _receiver; 42 private IAssetReceiver _receiver;
43 private BlockingQueue<ARequest> _assetRequests; 43 private BlockingQueue<ARequest> _assetRequests;
44 private Thread _remoteAssetServerThread; 44 private Thread _remoteAssetServerThread;
45 private string AssetServerUrl; 45 private string AssetServerUrl;
46 private string AssetSendKey; 46 private string AssetSendKey;
47 47
48 public RemoteAssetServer() 48 public RemoteAssetServer()
49 { 49 {
50 this._assetRequests = new BlockingQueue<ARequest>(); 50 this._assetRequests = new BlockingQueue<ARequest>();
51 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); 51 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
52 this._remoteAssetServerThread.IsBackground = true; 52 this._remoteAssetServerThread.IsBackground = true;
53 this._remoteAssetServerThread.Start(); 53 this._remoteAssetServerThread.Start();
54 MainLog.Instance.Verbose("Remote Asset Server class created"); 54 MainLog.Instance.Verbose("Remote Asset Server class created");
55 } 55 }
56 56
57 public void SetReceiver(IAssetReceiver receiver) 57 public void SetReceiver(IAssetReceiver receiver)
58 { 58 {
59 this._receiver = receiver; 59 this._receiver = receiver;
60 } 60 }
61 61
62 public void RequestAsset(LLUUID assetID, bool isTexture) 62 public void RequestAsset(LLUUID assetID, bool isTexture)
63 { 63 {
64 ARequest req = new ARequest(); 64 ARequest req = new ARequest();
65 req.AssetID = assetID; 65 req.AssetID = assetID;
66 req.IsTexture = isTexture; 66 req.IsTexture = isTexture;
67 this._assetRequests.Enqueue(req); 67 this._assetRequests.Enqueue(req);
68 } 68 }
69 69
70 public void UpdateAsset(AssetBase asset) 70 public void UpdateAsset(AssetBase asset)
71 { 71 {
72 72
73 } 73 }
74 74
75 public void UploadNewAsset(AssetBase asset) 75 public void UploadNewAsset(AssetBase asset)
76 { 76 {
77 Encoding Windows1252Encoding = Encoding.GetEncoding(1252); 77 Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
78 string ret = Windows1252Encoding.GetString(asset.Data); 78 string ret = Windows1252Encoding.GetString(asset.Data);
79 byte[] buffer = Windows1252Encoding.GetBytes(ret); 79 byte[] buffer = Windows1252Encoding.GetBytes(ret);
80 WebClient client = new WebClient(); 80 WebClient client = new WebClient();
81 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer); 81 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer);
82 82
83 } 83 }
84 84
85 public void SetServerInfo(string ServerUrl, string ServerKey) 85 public void SetServerInfo(string ServerUrl, string ServerKey)
86 { 86 {
87 this.AssetServerUrl = ServerUrl; 87 this.AssetServerUrl = ServerUrl;
88 this.AssetSendKey = ServerKey; 88 this.AssetSendKey = ServerKey;
89 } 89 }
90 90
91 private void RunRequests() 91 private void RunRequests()
92 { 92 {
93 while (true) 93 while (true)
94 { 94 {
95 //we need to add support for the asset server not knowing about a requested asset 95 //we need to add support for the asset server not knowing about a requested asset
96 // 404... THE MAGIC FILE NOT FOUND ERROR, very useful for telling you things such as a file (or asset ;) ) not being found!!!!!!!!!!! it's 2:22AM 96 // 404... THE MAGIC FILE NOT FOUND ERROR, very useful for telling you things such as a file (or asset ;) ) not being found!!!!!!!!!!! it's 2:22AM
97 ARequest req = this._assetRequests.Dequeue(); 97 ARequest req = this._assetRequests.Dequeue();
98 LLUUID assetID = req.AssetID; 98 LLUUID assetID = req.AssetID;
99 // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID); 99 // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID);
100 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID); 100 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID);
101 WebResponse AssetResponse = AssetLoad.GetResponse(); 101 WebResponse AssetResponse = AssetLoad.GetResponse();
102 byte[] idata = new byte[(int)AssetResponse.ContentLength]; 102 byte[] idata = new byte[(int)AssetResponse.ContentLength];
103 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); 103 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
104 idata = br.ReadBytes((int)AssetResponse.ContentLength); 104 idata = br.ReadBytes((int)AssetResponse.ContentLength);
105 br.Close(); 105 br.Close();
106 106
107 AssetBase asset = new AssetBase(); 107 AssetBase asset = new AssetBase();
108 asset.FullID = assetID; 108 asset.FullID = assetID;
109 asset.Data = idata; 109 asset.Data = idata;
110 _receiver.AssetReceived(asset, req.IsTexture); 110 _receiver.AssetReceived(asset, req.IsTexture);
111 } 111 }
112 } 112 }
113 113
114 public void Close() 114 public void Close()
115 { 115 {
116 116
117 } 117 }
118 } 118 }
119 119
120 public class RemoteAssetPlugin : IAssetPlugin 120 public class RemoteAssetPlugin : IAssetPlugin
121 { 121 {
122 public RemoteAssetPlugin() 122 public RemoteAssetPlugin()
123 { 123 {
124 124
125 } 125 }
126 126
127 public IAssetServer GetAssetServer() 127 public IAssetServer GetAssetServer()
128 { 128 {
129 return (new RemoteAssetServer()); 129 return (new RemoteAssetServer());
130 } 130 }
131 } 131 }
132 132
133} 133}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
index ce567a9..ecf8e68 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("PhysXplugin")] 36[assembly: AssemblyTitle("PhysXplugin")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("PhysXplugin")] 40[assembly: AssemblyProduct("PhysXplugin")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index f133045..ec406f1 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -1,301 +1,301 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using Axiom.Math; 29using Axiom.Math;
30using OpenSim.Physics.Manager; 30using OpenSim.Physics.Manager;
31 31
32namespace OpenSim.Region.Physics.BasicPhysicsPlugin 32namespace OpenSim.Region.Physics.BasicPhysicsPlugin
33{ 33{
34 /// <summary> 34 /// <summary>
35 /// Will be the PhysX plugin but for now will be a very basic physics engine 35 /// Will be the PhysX plugin but for now will be a very basic physics engine
36 /// </summary> 36 /// </summary>
37 public class BasicPhysicsPlugin : IPhysicsPlugin 37 public class BasicPhysicsPlugin : IPhysicsPlugin
38 { 38 {
39 private BasicScene _mScene; 39 private BasicScene _mScene;
40 40
41 public BasicPhysicsPlugin() 41 public BasicPhysicsPlugin()
42 { 42 {
43 43
44 } 44 }
45 45
46 public bool Init() 46 public bool Init()
47 { 47 {
48 return true; 48 return true;
49 } 49 }
50 50
51 public PhysicsScene GetScene() 51 public PhysicsScene GetScene()
52 { 52 {
53 return new BasicScene(); 53 return new BasicScene();
54 } 54 }
55 55
56 public string GetName() 56 public string GetName()
57 { 57 {
58 return("basicphysics"); 58 return("basicphysics");
59 } 59 }
60 60
61 public void Dispose() 61 public void Dispose()
62 { 62 {
63 63
64 } 64 }
65 } 65 }
66 66
67 public class BasicScene :PhysicsScene 67 public class BasicScene :PhysicsScene
68 { 68 {
69 private List<BasicActor> _actors = new List<BasicActor>(); 69 private List<BasicActor> _actors = new List<BasicActor>();
70 private float[] _heightMap; 70 private float[] _heightMap;
71 71
72 public BasicScene() 72 public BasicScene()
73 { 73 {
74 74
75 } 75 }
76 76
77 public override PhysicsActor AddAvatar(PhysicsVector position) 77 public override PhysicsActor AddAvatar(PhysicsVector position)
78 { 78 {
79 BasicActor act = new BasicActor(); 79 BasicActor act = new BasicActor();
80 act.Position = position; 80 act.Position = position;
81 _actors.Add(act); 81 _actors.Add(act);
82 return act; 82 return act;
83 } 83 }
84 84
85 public override void RemoveAvatar(PhysicsActor actor) 85 public override void RemoveAvatar(PhysicsActor actor)
86 { 86 {
87 BasicActor act = (BasicActor)actor; 87 BasicActor act = (BasicActor)actor;
88 if(_actors.Contains(act)) 88 if(_actors.Contains(act))
89 { 89 {
90 _actors.Remove(act); 90 _actors.Remove(act);
91 } 91 }
92 92
93 } 93 }
94 94
95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
96 { 96 {
97 return null; 97 return null;
98 } 98 }
99 99
100 public override void Simulate(float timeStep) 100 public override void Simulate(float timeStep)
101 { 101 {
102 foreach (BasicActor actor in _actors) 102 foreach (BasicActor actor in _actors)
103 { 103 {
104 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256)) 104 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
105 { 105 {
106 float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; 106 float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f;
107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); 107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); 108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
109 if (actor.Flying) 109 if (actor.Flying)
110 { 110 {
111 if (actor.Position.Z + (actor.Velocity.Z * timeStep) < 111 if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
112 _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2) 112 _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
113 { 113 {
114 actor.Position.Z = height; 114 actor.Position.Z = height;
115 actor.Velocity.Z = 0; 115 actor.Velocity.Z = 0;
116 } 116 }
117 else 117 else
118 { 118 {
119 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); 119 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
120 } 120 }
121 } 121 }
122 else 122 else
123 { 123 {
124 actor.Position.Z = height; 124 actor.Position.Z = height;
125 actor.Velocity.Z = 0; 125 actor.Velocity.Z = 0;
126 } 126 }
127 } 127 }
128 else 128 else
129 { 129 {
130 if (actor.Position.Y < 0) 130 if (actor.Position.Y < 0)
131 { 131 {
132 actor.Position.Y = 0; 132 actor.Position.Y = 0;
133 } 133 }
134 else if (actor.Position.Y > 256) 134 else if (actor.Position.Y > 256)
135 { 135 {
136 actor.Position.Y = 256; 136 actor.Position.Y = 256;
137 } 137 }
138 138
139 if (actor.Position.X < 0) 139 if (actor.Position.X < 0)
140 { 140 {
141 actor.Position.X = 0; 141 actor.Position.X = 0;
142 } 142 }
143 if (actor.Position.X > 256) 143 if (actor.Position.X > 256)
144 { 144 {
145 actor.Position.X = 256; 145 actor.Position.X = 256;
146 } 146 }
147 } 147 }
148 //} 148 //}
149 149
150 150
151 151
152 // This code needs sorting out - border crossings etc 152 // This code needs sorting out - border crossings etc
153/* if(actor.Position.X<0) 153/* if(actor.Position.X<0)
154 { 154 {
155 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 155 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
156 actor.Position.X = 0; 156 actor.Position.X = 0;
157 actor.Velocity.X = 0; 157 actor.Velocity.X = 0;
158 } 158 }
159 if(actor.Position.Y < 0) 159 if(actor.Position.Y < 0)
160 { 160 {
161 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 161 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
162 actor.Position.Y = 0; 162 actor.Position.Y = 0;
163 actor.Velocity.Y = 0; 163 actor.Velocity.Y = 0;
164 } 164 }
165 if(actor.Position.X > 255) 165 if(actor.Position.X > 255)
166 { 166 {
167 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 167 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
168 actor.Position.X = 255; 168 actor.Position.X = 255;
169 actor.Velocity.X = 0; 169 actor.Velocity.X = 0;
170 } 170 }
171 if(actor.Position.Y > 255) 171 if(actor.Position.Y > 255)
172 { 172 {
173 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 173 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
174 actor.Position.Y = 255; 174 actor.Position.Y = 255;
175 actor.Velocity.X = 0; 175 actor.Velocity.X = 0;
176 }*/ 176 }*/
177 } 177 }
178 } 178 }
179 179
180 public override void GetResults() 180 public override void GetResults()
181 { 181 {
182 182
183 } 183 }
184 184
185 public override bool IsThreaded 185 public override bool IsThreaded
186 { 186 {
187 get 187 get
188 { 188 {
189 return(false); // for now we won't be multithreaded 189 return(false); // for now we won't be multithreaded
190 } 190 }
191 } 191 }
192 192
193 public override void SetTerrain(float[] heightMap) 193 public override void SetTerrain(float[] heightMap)
194 { 194 {
195 this._heightMap = heightMap; 195 this._heightMap = heightMap;
196 } 196 }
197 197
198 public override void DeleteTerrain() 198 public override void DeleteTerrain()
199 { 199 {
200 200
201 } 201 }
202 } 202 }
203 203
204 public class BasicActor : PhysicsActor 204 public class BasicActor : PhysicsActor
205 { 205 {
206 private PhysicsVector _position; 206 private PhysicsVector _position;
207 private PhysicsVector _velocity; 207 private PhysicsVector _velocity;
208 private PhysicsVector _acceleration; 208 private PhysicsVector _acceleration;
209 private bool flying; 209 private bool flying;
210 public BasicActor() 210 public BasicActor()
211 { 211 {
212 _velocity = new PhysicsVector(); 212 _velocity = new PhysicsVector();
213 _position = new PhysicsVector(); 213 _position = new PhysicsVector();
214 _acceleration = new PhysicsVector(); 214 _acceleration = new PhysicsVector();
215 } 215 }
216 216
217 public override bool Flying 217 public override bool Flying
218 { 218 {
219 get 219 get
220 { 220 {
221 return flying; 221 return flying;
222 } 222 }
223 set 223 set
224 { 224 {
225 flying= value; 225 flying= value;
226 } 226 }
227 } 227 }
228 228
229 public override PhysicsVector Position 229 public override PhysicsVector Position
230 { 230 {
231 get 231 get
232 { 232 {
233 return _position; 233 return _position;
234 } 234 }
235 set 235 set
236 { 236 {
237 _position = value; 237 _position = value;
238 } 238 }
239 } 239 }
240 240
241 public override PhysicsVector Velocity 241 public override PhysicsVector Velocity
242 { 242 {
243 get 243 get
244 { 244 {
245 return _velocity; 245 return _velocity;
246 } 246 }
247 set 247 set
248 { 248 {
249 _velocity = value; 249 _velocity = value;
250 } 250 }
251 } 251 }
252 252
253 public override Quaternion Orientation 253 public override Quaternion Orientation
254 { 254 {
255 get 255 get
256 { 256 {
257 return Quaternion.Identity; 257 return Quaternion.Identity;
258 } 258 }
259 set 259 set
260 { 260 {
261 261
262 } 262 }
263 } 263 }
264 264
265 public override PhysicsVector Acceleration 265 public override PhysicsVector Acceleration
266 { 266 {
267 get 267 get
268 { 268 {
269 return _acceleration; 269 return _acceleration;
270 } 270 }
271 271
272 } 272 }
273 273
274 public override bool Kinematic 274 public override bool Kinematic
275 { 275 {
276 get 276 get
277 { 277 {
278 return true; 278 return true;
279 } 279 }
280 set 280 set
281 { 281 {
282 282
283 } 283 }
284 } 284 }
285 public void SetAcceleration (PhysicsVector accel) 285 public void SetAcceleration (PhysicsVector accel)
286 { 286 {
287 this._acceleration = accel; 287 this._acceleration = accel;
288 } 288 }
289 289
290 public override void AddForce(PhysicsVector force) 290 public override void AddForce(PhysicsVector force)
291 { 291 {
292 292
293 } 293 }
294 294
295 public override void SetMomentum(PhysicsVector momentum) 295 public override void SetMomentum(PhysicsVector momentum)
296 { 296 {
297 297
298 } 298 }
299 } 299 }
300 300
301} 301}
diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
index bda35f7..42ccdff 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("BulletXPlugin")] 36[assembly: AssemblyTitle("BulletXPlugin")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("BulletXPlugin")] 40[assembly: AssemblyProduct("BulletXPlugin")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.0.0")] 56[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 1ca5efe..383dbc0 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -1,534 +1,534 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28#region References 28#region References
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using OpenSim.Physics.Manager; 31using OpenSim.Physics.Manager;
32using Axiom.Math; 32using Axiom.Math;
33//Specific References for BulletXPlugin 33//Specific References for BulletXPlugin
34using MonoXnaCompactMaths; 34using MonoXnaCompactMaths;
35using XnaDevRu.BulletX; 35using XnaDevRu.BulletX;
36using XnaDevRu.BulletX.Dynamics; 36using XnaDevRu.BulletX.Dynamics;
37#endregion 37#endregion
38 38
39namespace OpenSim.Region.Physics.BulletXPlugin 39namespace OpenSim.Region.Physics.BulletXPlugin
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// This Class converts objects and types for BulletX 42 /// This Class converts objects and types for BulletX
43 /// </summary> 43 /// </summary>
44 public class BulletXConversions 44 public class BulletXConversions
45 { 45 {
46 public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector) 46 public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector)
47 { 47 {
48 return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z); 48 return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
49 } 49 }
50 public static void PhysicsVectorToXnaVector3(PhysicsVector physicsVector, out MonoXnaCompactMaths.Vector3 XnaVector3) 50 public static void PhysicsVectorToXnaVector3(PhysicsVector physicsVector, out MonoXnaCompactMaths.Vector3 XnaVector3)
51 { 51 {
52 XnaVector3.X = physicsVector.X; 52 XnaVector3.X = physicsVector.X;
53 XnaVector3.Y = physicsVector.Y; 53 XnaVector3.Y = physicsVector.Y;
54 XnaVector3.Z = physicsVector.Z; 54 XnaVector3.Z = physicsVector.Z;
55 } 55 }
56 public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3) 56 public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3)
57 { 57 {
58 return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z); 58 return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
59 } 59 }
60 /*public static void XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3, out PhysicsVector physicsVector) 60 /*public static void XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3, out PhysicsVector physicsVector)
61 { 61 {
62 xnaVector3.X = physicsVector.X; 62 xnaVector3.X = physicsVector.X;
63 xnaVector3.Y = physicsVector.Y; 63 xnaVector3.Y = physicsVector.Y;
64 xnaVector3.Z = physicsVector.Z; 64 xnaVector3.Z = physicsVector.Z;
65 }*/ 65 }*/
66 #region Axiom and Xna 66 #region Axiom and Xna
67 ///// <summary> 67 ///// <summary>
68 ///// BTW maybe some conversions will be a simply converion that it doesn't require this class, but i don't know 68 ///// BTW maybe some conversions will be a simply converion that it doesn't require this class, but i don't know
69 ///// </summary> 69 ///// </summary>
70 ///// <param name="AxiomVector3"></param> 70 ///// <param name="AxiomVector3"></param>
71 ///// <returns></returns> 71 ///// <returns></returns>
72 //public static MonoXnaCompactMaths.Vector3 Vector3AxiomToXna(Axiom.Math.Vector3 AxiomVector3) 72 //public static MonoXnaCompactMaths.Vector3 Vector3AxiomToXna(Axiom.Math.Vector3 AxiomVector3)
73 //{ 73 //{
74 // return new MonoXnaCompactMaths.Vector3(AxiomVector3.x, AxiomVector3.y, AxiomVector3.z); 74 // return new MonoXnaCompactMaths.Vector3(AxiomVector3.x, AxiomVector3.y, AxiomVector3.z);
75 //} 75 //}
76 #endregion 76 #endregion
77 } 77 }
78 /// <summary> 78 /// <summary>
79 /// PhysicsPlugin Class for BulletX 79 /// PhysicsPlugin Class for BulletX
80 /// </summary> 80 /// </summary>
81 public class BulletXPlugin : IPhysicsPlugin 81 public class BulletXPlugin : IPhysicsPlugin
82 { 82 {
83 private BulletXScene _mScene; 83 private BulletXScene _mScene;
84 84
85 public BulletXPlugin() 85 public BulletXPlugin()
86 { 86 {
87 } 87 }
88 public bool Init() 88 public bool Init()
89 { 89 {
90 return true; 90 return true;
91 } 91 }
92 public PhysicsScene GetScene() 92 public PhysicsScene GetScene()
93 { 93 {
94 if (_mScene == null) 94 if (_mScene == null)
95 { 95 {
96 _mScene = new BulletXScene(); 96 _mScene = new BulletXScene();
97 } 97 }
98 return (_mScene); 98 return (_mScene);
99 } 99 }
100 public string GetName() 100 public string GetName()
101 { 101 {
102 return ("BulletXEngine"); 102 return ("BulletXEngine");
103 } 103 }
104 public void Dispose() 104 public void Dispose()
105 { 105 {
106 } 106 }
107 } 107 }
108 /// <summary> 108 /// <summary>
109 /// PhysicsScene Class for BulletX 109 /// PhysicsScene Class for BulletX
110 /// </summary> 110 /// </summary>
111 public class BulletXScene : PhysicsScene 111 public class BulletXScene : PhysicsScene
112 { 112 {
113 public DiscreteDynamicsWorld ddWorld; 113 public DiscreteDynamicsWorld ddWorld;
114 private CollisionDispatcher cDispatcher; 114 private CollisionDispatcher cDispatcher;
115 private OverlappingPairCache opCache; 115 private OverlappingPairCache opCache;
116 private SequentialImpulseConstraintSolver sicSolver; 116 private SequentialImpulseConstraintSolver sicSolver;
117 117
118 private const int minXY = 0; 118 private const int minXY = 0;
119 private const int minZ = 0; 119 private const int minZ = 0;
120 private const int maxXY = 256; 120 private const int maxXY = 256;
121 private const int maxZ = 4096; 121 private const int maxZ = 4096;
122 private const int maxHandles = 32766; //Why? I don't know 122 private const int maxHandles = 32766; //Why? I don't know
123 private static float gravity = 9.8f; 123 private static float gravity = 9.8f;
124 private static float heightLevel0 = 77.0f; 124 private static float heightLevel0 = 77.0f;
125 private static float heightLevel1 = 200.0f; 125 private static float heightLevel1 = 200.0f;
126 private static float lowGravityFactor = 0.2f; 126 private static float lowGravityFactor = 0.2f;
127 127
128 private float[] _heightmap; 128 private float[] _heightmap;
129 private List<BulletXCharacter> _characters = new List<BulletXCharacter>(); 129 private List<BulletXCharacter> _characters = new List<BulletXCharacter>();
130 130
131 public static float Gravity { get { return gravity; } } 131 public static float Gravity { get { return gravity; } }
132 public static float HeightLevel0 { get { return heightLevel0; } } 132 public static float HeightLevel0 { get { return heightLevel0; } }
133 public static float HeightLevel1 { get { return heightLevel1; } } 133 public static float HeightLevel1 { get { return heightLevel1; } }
134 public static float LowGravityFactor { get { return lowGravityFactor; } } 134 public static float LowGravityFactor { get { return lowGravityFactor; } }
135 135
136 public BulletXScene() 136 public BulletXScene()
137 { 137 {
138 cDispatcher = new CollisionDispatcher(); 138 cDispatcher = new CollisionDispatcher();
139 MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ); 139 MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ);
140 MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ); 140 MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ);
141 opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles); 141 opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
142 sicSolver = new SequentialImpulseConstraintSolver(); 142 sicSolver = new SequentialImpulseConstraintSolver();
143 143
144 ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver); 144 ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
145 ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity); 145 ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity);
146 146
147 this._heightmap = new float[65536]; 147 this._heightmap = new float[65536];
148 } 148 }
149 149
150 public override PhysicsActor AddAvatar(PhysicsVector position) 150 public override PhysicsActor AddAvatar(PhysicsVector position)
151 { 151 {
152 PhysicsVector pos = new PhysicsVector(); 152 PhysicsVector pos = new PhysicsVector();
153 pos.X = position.X; 153 pos.X = position.X;
154 pos.Y = position.Y; 154 pos.Y = position.Y;
155 pos.Z = position.Z + 20; 155 pos.Z = position.Z + 20;
156 BulletXCharacter newAv = new BulletXCharacter(this, pos); 156 BulletXCharacter newAv = new BulletXCharacter(this, pos);
157 this._characters.Add(newAv); 157 this._characters.Add(newAv);
158 return newAv; 158 return newAv;
159 } 159 }
160 160
161 public override void RemoveAvatar(PhysicsActor actor) 161 public override void RemoveAvatar(PhysicsActor actor)
162 { 162 {
163 163
164 } 164 }
165 165
166 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 166 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
167 { 167 {
168 PhysicsVector pos = new PhysicsVector(); 168 PhysicsVector pos = new PhysicsVector();
169 pos.X = position.X; 169 pos.X = position.X;
170 pos.Y = position.Y; 170 pos.Y = position.Y;
171 pos.Z = position.Z; 171 pos.Z = position.Z;
172 PhysicsVector siz = new PhysicsVector(); 172 PhysicsVector siz = new PhysicsVector();
173 siz.X = size.X; 173 siz.X = size.X;
174 siz.Y = size.Y; 174 siz.Y = size.Y;
175 siz.Z = size.Z; 175 siz.Z = size.Z;
176 return new BulletXPrim(); 176 return new BulletXPrim();
177 } 177 }
178 178
179 public override void Simulate(float timeStep) 179 public override void Simulate(float timeStep)
180 { 180 {
181 foreach (BulletXCharacter actor in _characters) 181 foreach (BulletXCharacter actor in _characters)
182 { 182 {
183 actor.Move(timeStep); 183 actor.Move(timeStep);
184 184
185 } 185 }
186 ddWorld.StepSimulation(timeStep, 0, timeStep); 186 ddWorld.StepSimulation(timeStep, 0, timeStep);
187 foreach (BulletXCharacter actor in _characters) 187 foreach (BulletXCharacter actor in _characters)
188 { 188 {
189 actor.ValidateHeight(this._heightmap[ 189 actor.ValidateHeight(this._heightmap[
190 (int)Math.Round(actor.RigidBodyHorizontalPosition.x) * 256 190 (int)Math.Round(actor.RigidBodyHorizontalPosition.x) * 256
191 + (int)Math.Round(actor.RigidBodyHorizontalPosition.y)]); 191 + (int)Math.Round(actor.RigidBodyHorizontalPosition.y)]);
192 } 192 }
193 foreach (BulletXCharacter actor in _characters) 193 foreach (BulletXCharacter actor in _characters)
194 { 194 {
195 actor.UpdatePosition(); 195 actor.UpdatePosition();
196 } 196 }
197 197
198 } 198 }
199 199
200 public override void GetResults() 200 public override void GetResults()
201 { 201 {
202 202
203 } 203 }
204 204
205 public override bool IsThreaded 205 public override bool IsThreaded
206 { 206 {
207 get 207 get
208 { 208 {
209 return (false); // for now we won't be multithreaded 209 return (false); // for now we won't be multithreaded
210 } 210 }
211 } 211 }
212 212
213 public override void SetTerrain(float[] heightMap) 213 public override void SetTerrain(float[] heightMap)
214 { 214 {
215 //As the same as ODE, heightmap (x,y) must be swapped for BulletX 215 //As the same as ODE, heightmap (x,y) must be swapped for BulletX
216 for (int i = 0; i < 65536; i++) 216 for (int i = 0; i < 65536; i++)
217 { 217 {
218 // this._heightmap[i] = (double)heightMap[i]; 218 // this._heightmap[i] = (double)heightMap[i];
219 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...) 219 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
220 int x = i & 0xff; 220 int x = i & 0xff;
221 int y = i >> 8; 221 int y = i >> 8;
222 this._heightmap[i] = heightMap[x * 256 + y]; 222 this._heightmap[i] = heightMap[x * 256 + y];
223 } 223 }
224 } 224 }
225 225
226 public override void DeleteTerrain() 226 public override void DeleteTerrain()
227 { 227 {
228 228
229 } 229 }
230 } 230 }
231 /// <summary> 231 /// <summary>
232 /// PhysicsActor Character Class for BulletX 232 /// PhysicsActor Character Class for BulletX
233 /// </summary> 233 /// </summary>
234 public class BulletXCharacter : PhysicsActor 234 public class BulletXCharacter : PhysicsActor
235 { 235 {
236 private PhysicsVector _position; 236 private PhysicsVector _position;
237 private PhysicsVector _velocity; 237 private PhysicsVector _velocity;
238 private PhysicsVector _acceleration; 238 private PhysicsVector _acceleration;
239 private bool flying; 239 private bool flying;
240 private RigidBody rigidBody; 240 private RigidBody rigidBody;
241 public Axiom.Math.Vector2 RigidBodyHorizontalPosition 241 public Axiom.Math.Vector2 RigidBodyHorizontalPosition
242 { 242 {
243 get 243 get
244 { 244 {
245 return new Axiom.Math.Vector2(this.rigidBody.CenterOfMassPosition.X, this.rigidBody.CenterOfMassPosition.Y); 245 return new Axiom.Math.Vector2(this.rigidBody.CenterOfMassPosition.X, this.rigidBody.CenterOfMassPosition.Y);
246 } 246 }
247 } 247 }
248 public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos) 248 public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos)
249 { 249 {
250 _velocity = new PhysicsVector(); 250 _velocity = new PhysicsVector();
251 _position = pos; 251 _position = pos;
252 _acceleration = new PhysicsVector(); 252 _acceleration = new PhysicsVector();
253 float _mass = 50.0f; //This depends of avatar's dimensions 253 float _mass = 50.0f; //This depends of avatar's dimensions
254 Matrix _startTransform = Matrix.Identity; 254 Matrix _startTransform = Matrix.Identity;
255 _startTransform.Translation = BulletXConversions.PhysicsVectorToXnaVector3(pos); 255 _startTransform.Translation = BulletXConversions.PhysicsVectorToXnaVector3(pos);
256 Matrix _centerOfMassOffset = Matrix.Identity; 256 Matrix _centerOfMassOffset = Matrix.Identity;
257 CollisionShape _collisionShape = new BoxShape(new MonoXnaCompactMaths.Vector3(0.5f, 0.5f, 1.60f)); 257 CollisionShape _collisionShape = new BoxShape(new MonoXnaCompactMaths.Vector3(0.5f, 0.5f, 1.60f));
258 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 258 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
259 MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); 259 MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
260 _collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0 260 _collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0
261 261
262 //The next values might change 262 //The next values might change
263 float _linearDamping = 0.0f; 263 float _linearDamping = 0.0f;
264 float _angularDamping = 0.0f; 264 float _angularDamping = 0.0f;
265 float _friction = 0.5f; 265 float _friction = 0.5f;
266 float _restitution = 0.0f; 266 float _restitution = 0.0f;
267 267
268 rigidBody = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); 268 rigidBody = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
269 rigidBody.ActivationState = ActivationState.DisableDeactivation; 269 rigidBody.ActivationState = ActivationState.DisableDeactivation;
270 270
271 parent_scene.ddWorld.AddRigidBody(rigidBody); 271 parent_scene.ddWorld.AddRigidBody(rigidBody);
272 } 272 }
273 273
274 public override bool Flying 274 public override bool Flying
275 { 275 {
276 get 276 get
277 { 277 {
278 return flying; 278 return flying;
279 } 279 }
280 set 280 set
281 { 281 {
282 flying = value; 282 flying = value;
283 } 283 }
284 } 284 }
285 285
286 public override PhysicsVector Position 286 public override PhysicsVector Position
287 { 287 {
288 get 288 get
289 { 289 {
290 return _position; 290 return _position;
291 } 291 }
292 set 292 set
293 { 293 {
294 _position = value; 294 _position = value;
295 } 295 }
296 } 296 }
297 297
298 public override PhysicsVector Velocity 298 public override PhysicsVector Velocity
299 { 299 {
300 get 300 get
301 { 301 {
302 return _velocity; 302 return _velocity;
303 } 303 }
304 set 304 set
305 { 305 {
306 _velocity = value; 306 _velocity = value;
307 } 307 }
308 } 308 }
309 309
310 public override bool Kinematic 310 public override bool Kinematic
311 { 311 {
312 get 312 get
313 { 313 {
314 return false; 314 return false;
315 } 315 }
316 set 316 set
317 { 317 {
318 318
319 } 319 }
320 } 320 }
321 321
322 public override Axiom.Math.Quaternion Orientation 322 public override Axiom.Math.Quaternion Orientation
323 { 323 {
324 get 324 get
325 { 325 {
326 return Axiom.Math.Quaternion.Identity; 326 return Axiom.Math.Quaternion.Identity;
327 } 327 }
328 set 328 set
329 { 329 {
330 330
331 } 331 }
332 } 332 }
333 333
334 public override PhysicsVector Acceleration 334 public override PhysicsVector Acceleration
335 { 335 {
336 get 336 get
337 { 337 {
338 return _acceleration; 338 return _acceleration;
339 } 339 }
340 340
341 } 341 }
342 public void SetAcceleration(PhysicsVector accel) 342 public void SetAcceleration(PhysicsVector accel)
343 { 343 {
344 this._acceleration = accel; 344 this._acceleration = accel;
345 } 345 }
346 346
347 public override void AddForce(PhysicsVector force) 347 public override void AddForce(PhysicsVector force)
348 { 348 {
349 349
350 } 350 }
351 351
352 public override void SetMomentum(PhysicsVector momentum) 352 public override void SetMomentum(PhysicsVector momentum)
353 { 353 {
354 354
355 } 355 }
356 356
357 public void Move(float timeStep) 357 public void Move(float timeStep)
358 { 358 {
359 MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3(); 359 MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3();
360 //if (this._velocity.X == 0.0f) 360 //if (this._velocity.X == 0.0f)
361 // vec.X = this.rigidBody.LinearVelocity.X; //current velocity 361 // vec.X = this.rigidBody.LinearVelocity.X; //current velocity
362 //else 362 //else
363 vec.X = this._velocity.X; //overrides current velocity 363 vec.X = this._velocity.X; //overrides current velocity
364 364
365 //if (this._velocity.Y == 0.0f) 365 //if (this._velocity.Y == 0.0f)
366 // vec.Y = this.rigidBody.LinearVelocity.Y; //current velocity 366 // vec.Y = this.rigidBody.LinearVelocity.Y; //current velocity
367 //else 367 //else
368 vec.Y = this._velocity.Y; //overrides current velocity 368 vec.Y = this._velocity.Y; //overrides current velocity
369 369
370 float nextZVelocity; 370 float nextZVelocity;
371 //if (this._velocity.Z == 0.0f) 371 //if (this._velocity.Z == 0.0f)
372 // nextZVelocity = this.rigidBody.LinearVelocity.Z; //current velocity 372 // nextZVelocity = this.rigidBody.LinearVelocity.Z; //current velocity
373 //else 373 //else
374 nextZVelocity = this._velocity.Z; //overrides current velocity 374 nextZVelocity = this._velocity.Z; //overrides current velocity
375 375
376 if (flying) 376 if (flying)
377 { 377 {
378 //Antigravity with movement 378 //Antigravity with movement
379 if (this._position.Z <= BulletXScene.HeightLevel0) 379 if (this._position.Z <= BulletXScene.HeightLevel0)
380 { 380 {
381 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep; 381 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep;
382 } 382 }
383 //Lowgravity with movement 383 //Lowgravity with movement
384 else if((this._position.Z > BulletXScene.HeightLevel0) 384 else if((this._position.Z > BulletXScene.HeightLevel0)
385 && (this._position.Z <= BulletXScene.HeightLevel1)) 385 && (this._position.Z <= BulletXScene.HeightLevel1))
386 { 386 {
387 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); 387 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
388 } 388 }
389 //Lowgravity with... 389 //Lowgravity with...
390 else if (this._position.Z > BulletXScene.HeightLevel1) 390 else if (this._position.Z > BulletXScene.HeightLevel1)
391 { 391 {
392 if(nextZVelocity > 0) //no movement 392 if(nextZVelocity > 0) //no movement
393 vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); 393 vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
394 else 394 else
395 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); 395 vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
396 396
397 } 397 }
398 } 398 }
399 else 399 else
400 { 400 {
401 vec.Z = nextZVelocity; 401 vec.Z = nextZVelocity;
402 } 402 }
403 rigidBody.LinearVelocity = vec; 403 rigidBody.LinearVelocity = vec;
404 } 404 }
405 405
406 public void UpdatePosition() 406 public void UpdatePosition()
407 { 407 {
408 this._position = BulletXConversions.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); 408 this._position = BulletXConversions.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
409 } 409 }
410 410
411 //This validation is very basic 411 //This validation is very basic
412 internal void ValidateHeight(float heighmapPositionValue) 412 internal void ValidateHeight(float heighmapPositionValue)
413 { 413 {
414 if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue) 414 if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue)
415 { 415 {
416 Matrix m = rigidBody.WorldTransform; 416 Matrix m = rigidBody.WorldTransform;
417 MonoXnaCompactMaths.Vector3 v3 = m.Translation; 417 MonoXnaCompactMaths.Vector3 v3 = m.Translation;
418 v3.Z = heighmapPositionValue; 418 v3.Z = heighmapPositionValue;
419 m.Translation = v3; 419 m.Translation = v3;
420 rigidBody.WorldTransform = m; 420 rigidBody.WorldTransform = m;
421 } 421 }
422 } 422 }
423 } 423 }
424 /// <summary> 424 /// <summary>
425 /// PhysicsActor Prim Class for BulletX 425 /// PhysicsActor Prim Class for BulletX
426 /// </summary> 426 /// </summary>
427 public class BulletXPrim : PhysicsActor 427 public class BulletXPrim : PhysicsActor
428 { 428 {
429 private PhysicsVector _position; 429 private PhysicsVector _position;
430 private PhysicsVector _velocity; 430 private PhysicsVector _velocity;
431 private PhysicsVector _acceleration; 431 private PhysicsVector _acceleration;
432 432
433 public BulletXPrim() 433 public BulletXPrim()
434 { 434 {
435 _velocity = new PhysicsVector(); 435 _velocity = new PhysicsVector();
436 _position = new PhysicsVector(); 436 _position = new PhysicsVector();
437 _acceleration = new PhysicsVector(); 437 _acceleration = new PhysicsVector();
438 } 438 }
439 public override bool Flying 439 public override bool Flying
440 { 440 {
441 get 441 get
442 { 442 {
443 return false; //no flying prims for you 443 return false; //no flying prims for you
444 } 444 }
445 set 445 set
446 { 446 {
447 447
448 } 448 }
449 } 449 }
450 public override PhysicsVector Position 450 public override PhysicsVector Position
451 { 451 {
452 get 452 get
453 { 453 {
454 PhysicsVector pos = new PhysicsVector(); 454 PhysicsVector pos = new PhysicsVector();
455 // PhysicsVector vec = this._prim.Position; 455 // PhysicsVector vec = this._prim.Position;
456 //pos.X = vec.X; 456 //pos.X = vec.X;
457 //pos.Y = vec.Y; 457 //pos.Y = vec.Y;
458 //pos.Z = vec.Z; 458 //pos.Z = vec.Z;
459 return pos; 459 return pos;
460 460
461 } 461 }
462 set 462 set
463 { 463 {
464 /*PhysicsVector vec = value; 464 /*PhysicsVector vec = value;
465 PhysicsVector pos = new PhysicsVector(); 465 PhysicsVector pos = new PhysicsVector();
466 pos.X = vec.X; 466 pos.X = vec.X;
467 pos.Y = vec.Y; 467 pos.Y = vec.Y;
468 pos.Z = vec.Z; 468 pos.Z = vec.Z;
469 this._prim.Position = pos;*/ 469 this._prim.Position = pos;*/
470 } 470 }
471 } 471 }
472 472
473 public override PhysicsVector Velocity 473 public override PhysicsVector Velocity
474 { 474 {
475 get 475 get
476 { 476 {
477 return _velocity; 477 return _velocity;
478 } 478 }
479 set 479 set
480 { 480 {
481 _velocity = value; 481 _velocity = value;
482 } 482 }
483 } 483 }
484 484
485 public override bool Kinematic 485 public override bool Kinematic
486 { 486 {
487 get 487 get
488 { 488 {
489 return false; 489 return false;
490 //return this._prim.Kinematic; 490 //return this._prim.Kinematic;
491 } 491 }
492 set 492 set
493 { 493 {
494 //this._prim.Kinematic = value; 494 //this._prim.Kinematic = value;
495 } 495 }
496 } 496 }
497 497
498 public override Axiom.Math.Quaternion Orientation 498 public override Axiom.Math.Quaternion Orientation
499 { 499 {
500 get 500 get
501 { 501 {
502 Axiom.Math.Quaternion res = new Axiom.Math.Quaternion(); 502 Axiom.Math.Quaternion res = new Axiom.Math.Quaternion();
503 return res; 503 return res;
504 } 504 }
505 set 505 set
506 { 506 {
507 507
508 } 508 }
509 } 509 }
510 510
511 public override PhysicsVector Acceleration 511 public override PhysicsVector Acceleration
512 { 512 {
513 get 513 get
514 { 514 {
515 return _acceleration; 515 return _acceleration;
516 } 516 }
517 517
518 } 518 }
519 public void SetAcceleration(PhysicsVector accel) 519 public void SetAcceleration(PhysicsVector accel)
520 { 520 {
521 this._acceleration = accel; 521 this._acceleration = accel;
522 } 522 }
523 523
524 public override void AddForce(PhysicsVector force) 524 public override void AddForce(PhysicsVector force)
525 { 525 {
526 526
527 } 527 }
528 528
529 public override void SetMomentum(PhysicsVector momentum) 529 public override void SetMomentum(PhysicsVector momentum)
530 { 530 {
531 531
532 } 532 }
533 } 533 }
534} 534}
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
index 9415db9..27b467f 100644
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("PhysicsManager")] 36[assembly: AssemblyTitle("PhysicsManager")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("PhysicsManager")] 40[assembly: AssemblyProduct("PhysicsManager")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index da3b560..2c2c8dd 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -1,167 +1,167 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using Axiom.Math; 28using Axiom.Math;
29 29
30namespace OpenSim.Physics.Manager 30namespace OpenSim.Physics.Manager
31{ 31{
32 public delegate void PositionUpdate(PhysicsVector position); 32 public delegate void PositionUpdate(PhysicsVector position);
33 public delegate void VelocityUpdate(PhysicsVector velocity); 33 public delegate void VelocityUpdate(PhysicsVector velocity);
34 public delegate void OrientationUpdate(Quaternion orientation); 34 public delegate void OrientationUpdate(Quaternion orientation);
35 35
36 public abstract class PhysicsActor 36 public abstract class PhysicsActor
37 { 37 {
38 public event PositionUpdate OnPositionUpdate; 38 public event PositionUpdate OnPositionUpdate;
39 public event VelocityUpdate OnVelocityUpdate; 39 public event VelocityUpdate OnVelocityUpdate;
40 public event OrientationUpdate OnOrientationUpdate; 40 public event OrientationUpdate OnOrientationUpdate;
41 41
42 public static PhysicsActor Null 42 public static PhysicsActor Null
43 { 43 {
44 get 44 get
45 { 45 {
46 return new NullPhysicsActor(); 46 return new NullPhysicsActor();
47 } 47 }
48 } 48 }
49 49
50 public abstract PhysicsVector Position 50 public abstract PhysicsVector Position
51 { 51 {
52 get; 52 get;
53 set; 53 set;
54 } 54 }
55 55
56 public abstract PhysicsVector Velocity 56 public abstract PhysicsVector Velocity
57 { 57 {
58 get; 58 get;
59 set; 59 set;
60 } 60 }
61 61
62 public abstract PhysicsVector Acceleration 62 public abstract PhysicsVector Acceleration
63 { 63 {
64 get; 64 get;
65 } 65 }
66 66
67 public abstract Quaternion Orientation 67 public abstract Quaternion Orientation
68 { 68 {
69 get; 69 get;
70 set; 70 set;
71 } 71 }
72 72
73 public abstract bool Flying 73 public abstract bool Flying
74 { 74 {
75 get; 75 get;
76 set; 76 set;
77 } 77 }
78 78
79 public abstract bool Kinematic 79 public abstract bool Kinematic
80 { 80 {
81 get; 81 get;
82 set; 82 set;
83 } 83 }
84 84
85 public abstract void AddForce(PhysicsVector force); 85 public abstract void AddForce(PhysicsVector force);
86 86
87 public abstract void SetMomentum(PhysicsVector momentum); 87 public abstract void SetMomentum(PhysicsVector momentum);
88 } 88 }
89 89
90 public class NullPhysicsActor : PhysicsActor 90 public class NullPhysicsActor : PhysicsActor
91 { 91 {
92 public override PhysicsVector Position 92 public override PhysicsVector Position
93 { 93 {
94 get 94 get
95 { 95 {
96 return PhysicsVector.Zero; 96 return PhysicsVector.Zero;
97 } 97 }
98 set 98 set
99 { 99 {
100 return; 100 return;
101 } 101 }
102 } 102 }
103 103
104 public override PhysicsVector Velocity 104 public override PhysicsVector Velocity
105 { 105 {
106 get 106 get
107 { 107 {
108 return PhysicsVector.Zero; 108 return PhysicsVector.Zero;
109 } 109 }
110 set 110 set
111 { 111 {
112 return; 112 return;
113 } 113 }
114 } 114 }
115 115
116 public override Quaternion Orientation 116 public override Quaternion Orientation
117 { 117 {
118 get 118 get
119 { 119 {
120 return Quaternion.Identity; 120 return Quaternion.Identity;
121 } 121 }
122 set 122 set
123 { 123 {
124 124
125 } 125 }
126 } 126 }
127 127
128 public override PhysicsVector Acceleration 128 public override PhysicsVector Acceleration
129 { 129 {
130 get { return PhysicsVector.Zero; } 130 get { return PhysicsVector.Zero; }
131 } 131 }
132 132
133 public override bool Flying 133 public override bool Flying
134 { 134 {
135 get 135 get
136 { 136 {
137 return false; 137 return false;
138 } 138 }
139 set 139 set
140 { 140 {
141 return; 141 return;
142 } 142 }
143 } 143 }
144 144
145 public override bool Kinematic 145 public override bool Kinematic
146 { 146 {
147 get 147 get
148 { 148 {
149 return true; 149 return true;
150 } 150 }
151 set 151 set
152 { 152 {
153 return; 153 return;
154 } 154 }
155 } 155 }
156 156
157 public override void AddForce(PhysicsVector force) 157 public override void AddForce(PhysicsVector force)
158 { 158 {
159 return; 159 return;
160 } 160 }
161 161
162 public override void SetMomentum(PhysicsVector momentum) 162 public override void SetMomentum(PhysicsVector momentum)
163 { 163 {
164 return; 164 return;
165 } 165 }
166 } 166 }
167} 167}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsManager.cs b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
index 265bce6..7c475e7 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
@@ -1,115 +1,115 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using OpenSim.Framework.Console; 32using OpenSim.Framework.Console;
33 33
34namespace OpenSim.Physics.Manager 34namespace OpenSim.Physics.Manager
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// Description of MyClass. 37 /// Description of MyClass.
38 /// </summary> 38 /// </summary>
39 public class PhysicsManager 39 public class PhysicsManager
40 { 40 {
41 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>(); 41 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
42 42
43 public PhysicsManager() 43 public PhysicsManager()
44 { 44 {
45 45
46 } 46 }
47 47
48 public PhysicsScene GetPhysicsScene(string engineName) 48 public PhysicsScene GetPhysicsScene(string engineName)
49 { 49 {
50 if (String.IsNullOrEmpty(engineName)) 50 if (String.IsNullOrEmpty(engineName))
51 { 51 {
52 return PhysicsScene.Null; 52 return PhysicsScene.Null;
53 } 53 }
54 54
55 if(_plugins.ContainsKey(engineName)) 55 if(_plugins.ContainsKey(engineName))
56 { 56 {
57 MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName); 57 MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
58 return _plugins[engineName].GetScene(); 58 return _plugins[engineName].GetScene();
59 } 59 }
60 else 60 else
61 { 61 {
62 MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName); 62 MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
63 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName)); 63 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
64 } 64 }
65 } 65 }
66 66
67 public void LoadPlugins() 67 public void LoadPlugins()
68 { 68 {
69 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics"); 69 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics");
70 string[] pluginFiles = Directory.GetFiles(path, "*.dll"); 70 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
71 71
72 72
73 for(int i= 0; i<pluginFiles.Length; i++) 73 for(int i= 0; i<pluginFiles.Length; i++)
74 { 74 {
75 this.AddPlugin(pluginFiles[i]); 75 this.AddPlugin(pluginFiles[i]);
76 } 76 }
77 } 77 }
78 78
79 private void AddPlugin(string FileName) 79 private void AddPlugin(string FileName)
80 { 80 {
81 Assembly pluginAssembly = Assembly.LoadFrom(FileName); 81 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
82 82
83 foreach (Type pluginType in pluginAssembly.GetTypes()) 83 foreach (Type pluginType in pluginAssembly.GetTypes())
84 { 84 {
85 if (pluginType.IsPublic) 85 if (pluginType.IsPublic)
86 { 86 {
87 if (!pluginType.IsAbstract) 87 if (!pluginType.IsAbstract)
88 { 88 {
89 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); 89 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
90 90
91 if (typeInterface != null) 91 if (typeInterface != null)
92 { 92 {
93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 93 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
94 plug.Init(); 94 plug.Init();
95 this._plugins.Add(plug.GetName(),plug); 95 this._plugins.Add(plug.GetName(),plug);
96 96
97 } 97 }
98 98
99 typeInterface = null; 99 typeInterface = null;
100 } 100 }
101 } 101 }
102 } 102 }
103 103
104 pluginAssembly = null; 104 pluginAssembly = null;
105 } 105 }
106 } 106 }
107 107
108 public interface IPhysicsPlugin 108 public interface IPhysicsPlugin
109 { 109 {
110 bool Init(); 110 bool Init();
111 PhysicsScene GetScene(); 111 PhysicsScene GetScene();
112 string GetName(); 112 string GetName();
113 void Dispose(); 113 void Dispose();
114 } 114 }
115} 115}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index d44da00..fb6358a 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -1,110 +1,110 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using OpenSim.Framework.Console; 28using OpenSim.Framework.Console;
29 29
30namespace OpenSim.Physics.Manager 30namespace OpenSim.Physics.Manager
31{ 31{
32 public abstract class PhysicsScene 32 public abstract class PhysicsScene
33 { 33 {
34 public static PhysicsScene Null 34 public static PhysicsScene Null
35 { 35 {
36 get 36 get
37 { 37 {
38 return new NullPhysicsScene(); 38 return new NullPhysicsScene();
39 } 39 }
40 } 40 }
41 41
42 public abstract PhysicsActor AddAvatar(PhysicsVector position); 42 public abstract PhysicsActor AddAvatar(PhysicsVector position);
43 43
44 public abstract void RemoveAvatar(PhysicsActor actor); 44 public abstract void RemoveAvatar(PhysicsActor actor);
45 45
46 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); 46 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
47 47
48 public abstract void Simulate(float timeStep); 48 public abstract void Simulate(float timeStep);
49 49
50 public abstract void GetResults(); 50 public abstract void GetResults();
51 51
52 public abstract void SetTerrain(float[] heightMap); 52 public abstract void SetTerrain(float[] heightMap);
53 53
54 public abstract void DeleteTerrain(); 54 public abstract void DeleteTerrain();
55 55
56 public abstract bool IsThreaded 56 public abstract bool IsThreaded
57 { 57 {
58 get; 58 get;
59 } 59 }
60 60
61 private class NullPhysicsScene : PhysicsScene 61 private class NullPhysicsScene : PhysicsScene
62 { 62 {
63 private static int m_workIndicator; 63 private static int m_workIndicator;
64 64
65 public override PhysicsActor AddAvatar(PhysicsVector position) 65 public override PhysicsActor AddAvatar(PhysicsVector position)
66 { 66 {
67 MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position); 67 MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position);
68 return PhysicsActor.Null; 68 return PhysicsActor.Null;
69 } 69 }
70 70
71 public override void RemoveAvatar(PhysicsActor actor) 71 public override void RemoveAvatar(PhysicsActor actor)
72 { 72 {
73 73
74 } 74 }
75 75
76 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 76 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
77 { 77 {
78 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); 78 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size);
79 return PhysicsActor.Null; 79 return PhysicsActor.Null;
80 } 80 }
81 81
82 public override void Simulate(float timeStep) 82 public override void Simulate(float timeStep)
83 { 83 {
84 m_workIndicator = (m_workIndicator + 1) % 10; 84 m_workIndicator = (m_workIndicator + 1) % 10;
85 85
86 //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString()); 86 //OpenSim.Framework.Console.MainLog.Instance.SetStatus(m_workIndicator.ToString());
87 } 87 }
88 88
89 public override void GetResults() 89 public override void GetResults()
90 { 90 {
91 MainLog.Instance.Verbose("NullPhysicsScene : GetResults()"); 91 MainLog.Instance.Verbose("NullPhysicsScene : GetResults()");
92 } 92 }
93 93
94 public override void SetTerrain(float[] heightMap) 94 public override void SetTerrain(float[] heightMap)
95 { 95 {
96 MainLog.Instance.Verbose("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); 96 MainLog.Instance.Verbose("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
97 } 97 }
98 98
99 public override void DeleteTerrain() 99 public override void DeleteTerrain()
100 { 100 {
101 101
102 } 102 }
103 103
104 public override bool IsThreaded 104 public override bool IsThreaded
105 { 105 {
106 get { return false; } 106 get { return false; }
107 } 107 }
108 } 108 }
109 } 109 }
110} 110}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
index e75f29b..2cbca25 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -1,55 +1,55 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Physics.Manager 28namespace OpenSim.Physics.Manager
29{ 29{
30 public class PhysicsVector 30 public class PhysicsVector
31 { 31 {
32 public float X; 32 public float X;
33 public float Y; 33 public float Y;
34 public float Z; 34 public float Z;
35 35
36 public PhysicsVector() 36 public PhysicsVector()
37 { 37 {
38 38
39 } 39 }
40 40
41 public PhysicsVector(float x, float y, float z) 41 public PhysicsVector(float x, float y, float z)
42 { 42 {
43 X = x; 43 X = x;
44 Y = y; 44 Y = y;
45 Z = z; 45 Z = z;
46 } 46 }
47 47
48 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f); 48 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
49 49
50 public override string ToString() 50 public override string ToString()
51 { 51 {
52 return "<" + this.X + "," + this.Y + "," + this.Z + ">"; 52 return "<" + this.X + "," + this.Y + "," + this.Z + ">";
53 } 53 }
54 } 54 }
55} 55}
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
index ee10430..662b75a 100644
--- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("RealPhysXplugin")] 36[assembly: AssemblyTitle("RealPhysXplugin")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RealPhysXplugin")] 40[assembly: AssemblyProduct("RealPhysXplugin")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 2780188..486fa9e 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -1,457 +1,457 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Axiom.Math; 30using Axiom.Math;
31using Ode.NET; 31using Ode.NET;
32using OpenSim.Physics.Manager; 32using OpenSim.Physics.Manager;
33 33
34namespace OpenSim.Region.Physics.OdePlugin 34namespace OpenSim.Region.Physics.OdePlugin
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// ODE plugin 37 /// ODE plugin
38 /// </summary> 38 /// </summary>
39 public class OdePlugin : IPhysicsPlugin 39 public class OdePlugin : IPhysicsPlugin
40 { 40 {
41 private OdeScene _mScene; 41 private OdeScene _mScene;
42 42
43 public OdePlugin() 43 public OdePlugin()
44 { 44 {
45 45
46 } 46 }
47 47
48 public bool Init() 48 public bool Init()
49 { 49 {
50 return true; 50 return true;
51 } 51 }
52 52
53 public PhysicsScene GetScene() 53 public PhysicsScene GetScene()
54 { 54 {
55 if (_mScene == null) 55 if (_mScene == null)
56 { 56 {
57 _mScene = new OdeScene(); 57 _mScene = new OdeScene();
58 } 58 }
59 return (_mScene); 59 return (_mScene);
60 } 60 }
61 61
62 public string GetName() 62 public string GetName()
63 { 63 {
64 return ("OpenDynamicsEngine"); 64 return ("OpenDynamicsEngine");
65 } 65 }
66 66
67 public void Dispose() 67 public void Dispose()
68 { 68 {
69 69
70 } 70 }
71 } 71 }
72 72
73 public class OdeScene : PhysicsScene 73 public class OdeScene : PhysicsScene
74 { 74 {
75 static public IntPtr world; 75 static public IntPtr world;
76 static public IntPtr space; 76 static public IntPtr space;
77 static private IntPtr contactgroup; 77 static private IntPtr contactgroup;
78 static private IntPtr LandGeom; 78 static private IntPtr LandGeom;
79 //static private IntPtr Land; 79 //static private IntPtr Land;
80 private double[] _heightmap; 80 private double[] _heightmap;
81 static private d.NearCallback nearCallback = near; 81 static private d.NearCallback nearCallback = near;
82 private List<OdeCharacter> _characters = new List<OdeCharacter>(); 82 private List<OdeCharacter> _characters = new List<OdeCharacter>();
83 private static d.ContactGeom[] contacts = new d.ContactGeom[30]; 83 private static d.ContactGeom[] contacts = new d.ContactGeom[30];
84 private static d.Contact contact; 84 private static d.Contact contact;
85 85
86 public OdeScene() 86 public OdeScene()
87 { 87 {
88 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; 88 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
89 contact.surface.mu = d.Infinity; 89 contact.surface.mu = d.Infinity;
90 contact.surface.mu2 = 0.0f; 90 contact.surface.mu2 = 0.0f;
91 contact.surface.bounce = 0.1f; 91 contact.surface.bounce = 0.1f;
92 contact.surface.bounce_vel = 0.1f; 92 contact.surface.bounce_vel = 0.1f;
93 contact.surface.soft_cfm = 0.01f; 93 contact.surface.soft_cfm = 0.01f;
94 94
95 world = d.WorldCreate(); 95 world = d.WorldCreate();
96 space = d.HashSpaceCreate(IntPtr.Zero); 96 space = d.HashSpaceCreate(IntPtr.Zero);
97 contactgroup = d.JointGroupCreate(0); 97 contactgroup = d.JointGroupCreate(0);
98 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); 98 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
99 //d.WorldSetCFM(world, 1e-5f); 99 //d.WorldSetCFM(world, 1e-5f);
100 d.WorldSetAutoDisableFlag(world, false); 100 d.WorldSetAutoDisableFlag(world, false);
101 d.WorldSetContactSurfaceLayer(world, 0.001f); 101 d.WorldSetContactSurfaceLayer(world, 0.001f);
102 // d.CreatePlane(space, 0, 0, 1, 0); 102 // d.CreatePlane(space, 0, 0, 1, 0);
103 this._heightmap = new double[65536]; 103 this._heightmap = new double[65536];
104 } 104 }
105 105
106 // This function blatantly ripped off from BoxStack.cs 106 // This function blatantly ripped off from BoxStack.cs
107 static private void near(IntPtr space, IntPtr g1, IntPtr g2) 107 static private void near(IntPtr space, IntPtr g1, IntPtr g2)
108 { 108 {
109 IntPtr b1 = d.GeomGetBody(g1); 109 IntPtr b1 = d.GeomGetBody(g1);
110 IntPtr b2 = d.GeomGetBody(g2); 110 IntPtr b2 = d.GeomGetBody(g2);
111 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 111 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
112 return; 112 return;
113 113
114 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); 114 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
115 for (int i = 0; i < count; ++i) 115 for (int i = 0; i < count; ++i)
116 { 116 {
117 contact.geom = contacts[i]; 117 contact.geom = contacts[i];
118 IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); 118 IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
119 d.JointAttach(joint, b1, b2); 119 d.JointAttach(joint, b1, b2);
120 } 120 }
121 121
122 } 122 }
123 123
124 public override PhysicsActor AddAvatar(PhysicsVector position) 124 public override PhysicsActor AddAvatar(PhysicsVector position)
125 { 125 {
126 PhysicsVector pos = new PhysicsVector(); 126 PhysicsVector pos = new PhysicsVector();
127 pos.X = position.X; 127 pos.X = position.X;
128 pos.Y = position.Y; 128 pos.Y = position.Y;
129 pos.Z = position.Z + 20; 129 pos.Z = position.Z + 20;
130 OdeCharacter newAv = new OdeCharacter(this, pos); 130 OdeCharacter newAv = new OdeCharacter(this, pos);
131 this._characters.Add(newAv); 131 this._characters.Add(newAv);
132 return newAv; 132 return newAv;
133 } 133 }
134 134
135 public override void RemoveAvatar(PhysicsActor actor) 135 public override void RemoveAvatar(PhysicsActor actor)
136 { 136 {
137 137
138 } 138 }
139 139
140 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 140 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
141 { 141 {
142 PhysicsVector pos = new PhysicsVector(); 142 PhysicsVector pos = new PhysicsVector();
143 pos.X = position.X; 143 pos.X = position.X;
144 pos.Y = position.Y; 144 pos.Y = position.Y;
145 pos.Z = position.Z; 145 pos.Z = position.Z;
146 PhysicsVector siz = new PhysicsVector(); 146 PhysicsVector siz = new PhysicsVector();
147 siz.X = size.X; 147 siz.X = size.X;
148 siz.Y = size.Y; 148 siz.Y = size.Y;
149 siz.Z = size.Z; 149 siz.Z = size.Z;
150 return new OdePrim(); 150 return new OdePrim();
151 } 151 }
152 152
153 public override void Simulate(float timeStep) 153 public override void Simulate(float timeStep)
154 { 154 {
155 foreach (OdeCharacter actor in _characters) 155 foreach (OdeCharacter actor in _characters)
156 { 156 {
157 actor.Move(timeStep * 5f); 157 actor.Move(timeStep * 5f);
158 } 158 }
159 d.SpaceCollide(space, IntPtr.Zero, nearCallback); 159 d.SpaceCollide(space, IntPtr.Zero, nearCallback);
160 d.WorldQuickStep(world, timeStep * 5f); 160 d.WorldQuickStep(world, timeStep * 5f);
161 d.JointGroupEmpty(contactgroup); 161 d.JointGroupEmpty(contactgroup);
162 foreach (OdeCharacter actor in _characters) 162 foreach (OdeCharacter actor in _characters)
163 { 163 {
164 actor.UpdatePosition(); 164 actor.UpdatePosition();
165 } 165 }
166 166
167 } 167 }
168 168
169 public override void GetResults() 169 public override void GetResults()
170 { 170 {
171 171
172 } 172 }
173 173
174 public override bool IsThreaded 174 public override bool IsThreaded
175 { 175 {
176 get 176 get
177 { 177 {
178 return (false); // for now we won't be multithreaded 178 return (false); // for now we won't be multithreaded
179 } 179 }
180 } 180 }
181 181
182 public override void SetTerrain(float[] heightMap) 182 public override void SetTerrain(float[] heightMap)
183 { 183 {
184 for (int i = 0; i < 65536; i++) 184 for (int i = 0; i < 65536; i++)
185 { 185 {
186 // this._heightmap[i] = (double)heightMap[i]; 186 // this._heightmap[i] = (double)heightMap[i];
187 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...) 187 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
188 int x = i & 0xff; 188 int x = i & 0xff;
189 int y = i >> 8; 189 int y = i >> 8;
190 this._heightmap[i] = (double)heightMap[x * 256 + y]; 190 this._heightmap[i] = (double)heightMap[x * 256 + y];
191 } 191 }
192 IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); 192 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
193 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); 193 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
194 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); 194 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
195 LandGeom = d.CreateHeightfield(space, HeightmapData, 1); 195 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
196 d.Matrix3 R = new d.Matrix3(); 196 d.Matrix3 R = new d.Matrix3();
197 197
198 Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0)); 198 Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0));
199 Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0)); 199 Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0));
200 //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); 200 //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
201 201
202 q1 = q1 * q2; 202 q1 = q1 * q2;
203 //q1 = q1 * q3; 203 //q1 = q1 * q3;
204 Vector3 v3 = new Vector3(); 204 Vector3 v3 = new Vector3();
205 float angle = 0; 205 float angle = 0;
206 q1.ToAngleAxis(ref angle, ref v3); 206 q1.ToAngleAxis(ref angle, ref v3);
207 207
208 d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); 208 d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
209 d.GeomSetRotation(LandGeom, ref R); 209 d.GeomSetRotation(LandGeom, ref R);
210 d.GeomSetPosition(LandGeom, 128, 128, 0); 210 d.GeomSetPosition(LandGeom, 128, 128, 0);
211 } 211 }
212 212
213 public override void DeleteTerrain() 213 public override void DeleteTerrain()
214 { 214 {
215 215
216 } 216 }
217 } 217 }
218 218
219 public class OdeCharacter : PhysicsActor 219 public class OdeCharacter : PhysicsActor
220 { 220 {
221 private PhysicsVector _position; 221 private PhysicsVector _position;
222 private PhysicsVector _velocity; 222 private PhysicsVector _velocity;
223 private PhysicsVector _acceleration; 223 private PhysicsVector _acceleration;
224 private bool flying; 224 private bool flying;
225 //private float gravityAccel; 225 //private float gravityAccel;
226 private IntPtr BoundingCapsule; 226 private IntPtr BoundingCapsule;
227 IntPtr capsule_geom; 227 IntPtr capsule_geom;
228 d.Mass capsule_mass; 228 d.Mass capsule_mass;
229 229
230 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) 230 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
231 { 231 {
232 _velocity = new PhysicsVector(); 232 _velocity = new PhysicsVector();
233 _position = pos; 233 _position = pos;
234 _acceleration = new PhysicsVector(); 234 _acceleration = new PhysicsVector();
235 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); 235 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
236 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); 236 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
237 this.BoundingCapsule = d.BodyCreate(OdeScene.world); 237 this.BoundingCapsule = d.BodyCreate(OdeScene.world);
238 d.BodySetMass(BoundingCapsule, ref capsule_mass); 238 d.BodySetMass(BoundingCapsule, ref capsule_mass);
239 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); 239 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
240 d.GeomSetBody(capsule_geom, BoundingCapsule); 240 d.GeomSetBody(capsule_geom, BoundingCapsule);
241 } 241 }
242 242
243 public override bool Flying 243 public override bool Flying
244 { 244 {
245 get 245 get
246 { 246 {
247 return flying; 247 return flying;
248 } 248 }
249 set 249 set
250 { 250 {
251 flying = value; 251 flying = value;
252 } 252 }
253 } 253 }
254 254
255 public override PhysicsVector Position 255 public override PhysicsVector Position
256 { 256 {
257 get 257 get
258 { 258 {
259 return _position; 259 return _position;
260 } 260 }
261 set 261 set
262 { 262 {
263 _position = value; 263 _position = value;
264 } 264 }
265 } 265 }
266 266
267 public override PhysicsVector Velocity 267 public override PhysicsVector Velocity
268 { 268 {
269 get 269 get
270 { 270 {
271 return _velocity; 271 return _velocity;
272 } 272 }
273 set 273 set
274 { 274 {
275 _velocity = value; 275 _velocity = value;
276 } 276 }
277 } 277 }
278 278
279 public override bool Kinematic 279 public override bool Kinematic
280 { 280 {
281 get 281 get
282 { 282 {
283 return false; 283 return false;
284 } 284 }
285 set 285 set
286 { 286 {
287 287
288 } 288 }
289 } 289 }
290 290
291 public override Quaternion Orientation 291 public override Quaternion Orientation
292 { 292 {
293 get 293 get
294 { 294 {
295 return Quaternion.Identity; 295 return Quaternion.Identity;
296 } 296 }
297 set 297 set
298 { 298 {
299 299
300 } 300 }
301 } 301 }
302 302
303 public override PhysicsVector Acceleration 303 public override PhysicsVector Acceleration
304 { 304 {
305 get 305 get
306 { 306 {
307 return _acceleration; 307 return _acceleration;
308 } 308 }
309 309
310 } 310 }
311 public void SetAcceleration(PhysicsVector accel) 311 public void SetAcceleration(PhysicsVector accel)
312 { 312 {
313 this._acceleration = accel; 313 this._acceleration = accel;
314 } 314 }
315 315
316 public override void AddForce(PhysicsVector force) 316 public override void AddForce(PhysicsVector force)
317 { 317 {
318 318
319 } 319 }
320 320
321 public override void SetMomentum(PhysicsVector momentum) 321 public override void SetMomentum(PhysicsVector momentum)
322 { 322 {
323 323
324 } 324 }
325 325
326 public void Move(float timeStep) 326 public void Move(float timeStep)
327 { 327 {
328 PhysicsVector vec = new PhysicsVector(); 328 PhysicsVector vec = new PhysicsVector();
329 vec.X = this._velocity.X * timeStep; 329 vec.X = this._velocity.X * timeStep;
330 vec.Y = this._velocity.Y * timeStep; 330 vec.Y = this._velocity.Y * timeStep;
331 if (flying) 331 if (flying)
332 { 332 {
333 vec.Z = (this._velocity.Z + 0.5f) * timeStep; 333 vec.Z = (this._velocity.Z + 0.5f) * timeStep;
334 } 334 }
335 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); 335 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
336 } 336 }
337 337
338 public void UpdatePosition() 338 public void UpdatePosition()
339 { 339 {
340 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); 340 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
341 this._position.X = vec.X; 341 this._position.X = vec.X;
342 this._position.Y = vec.Y; 342 this._position.Y = vec.Y;
343 this._position.Z = vec.Z+1.0f; 343 this._position.Z = vec.Z+1.0f;
344 } 344 }
345 } 345 }
346 346
347 public class OdePrim : PhysicsActor 347 public class OdePrim : PhysicsActor
348 { 348 {
349 private PhysicsVector _position; 349 private PhysicsVector _position;
350 private PhysicsVector _velocity; 350 private PhysicsVector _velocity;
351 private PhysicsVector _acceleration; 351 private PhysicsVector _acceleration;
352 352
353 public OdePrim() 353 public OdePrim()
354 { 354 {
355 _velocity = new PhysicsVector(); 355 _velocity = new PhysicsVector();
356 _position = new PhysicsVector(); 356 _position = new PhysicsVector();
357 _acceleration = new PhysicsVector(); 357 _acceleration = new PhysicsVector();
358 } 358 }
359 public override bool Flying 359 public override bool Flying
360 { 360 {
361 get 361 get
362 { 362 {
363 return false; //no flying prims for you 363 return false; //no flying prims for you
364 } 364 }
365 set 365 set
366 { 366 {
367 367
368 } 368 }
369 } 369 }
370 public override PhysicsVector Position 370 public override PhysicsVector Position
371 { 371 {
372 get 372 get
373 { 373 {
374 PhysicsVector pos = new PhysicsVector(); 374 PhysicsVector pos = new PhysicsVector();
375 // PhysicsVector vec = this._prim.Position; 375 // PhysicsVector vec = this._prim.Position;
376 //pos.X = vec.X; 376 //pos.X = vec.X;
377 //pos.Y = vec.Y; 377 //pos.Y = vec.Y;
378 //pos.Z = vec.Z; 378 //pos.Z = vec.Z;
379 return pos; 379 return pos;
380 380
381 } 381 }
382 set 382 set
383 { 383 {
384 /*PhysicsVector vec = value; 384 /*PhysicsVector vec = value;
385 PhysicsVector pos = new PhysicsVector(); 385 PhysicsVector pos = new PhysicsVector();
386 pos.X = vec.X; 386 pos.X = vec.X;
387 pos.Y = vec.Y; 387 pos.Y = vec.Y;
388 pos.Z = vec.Z; 388 pos.Z = vec.Z;
389 this._prim.Position = pos;*/ 389 this._prim.Position = pos;*/
390 } 390 }
391 } 391 }
392 392
393 public override PhysicsVector Velocity 393 public override PhysicsVector Velocity
394 { 394 {
395 get 395 get
396 { 396 {
397 return _velocity; 397 return _velocity;
398 } 398 }
399 set 399 set
400 { 400 {
401 _velocity = value; 401 _velocity = value;
402 } 402 }
403 } 403 }
404 404
405 public override bool Kinematic 405 public override bool Kinematic
406 { 406 {
407 get 407 get
408 { 408 {
409 return false; 409 return false;
410 //return this._prim.Kinematic; 410 //return this._prim.Kinematic;
411 } 411 }
412 set 412 set
413 { 413 {
414 //this._prim.Kinematic = value; 414 //this._prim.Kinematic = value;
415 } 415 }
416 } 416 }
417 417
418 public override Quaternion Orientation 418 public override Quaternion Orientation
419 { 419 {
420 get 420 get
421 { 421 {
422 Quaternion res = new Quaternion(); 422 Quaternion res = new Quaternion();
423 return res; 423 return res;
424 } 424 }
425 set 425 set
426 { 426 {
427 427
428 } 428 }
429 } 429 }
430 430
431 public override PhysicsVector Acceleration 431 public override PhysicsVector Acceleration
432 { 432 {
433 get 433 get
434 { 434 {
435 return _acceleration; 435 return _acceleration;
436 } 436 }
437 437
438 } 438 }
439 public void SetAcceleration(PhysicsVector accel) 439 public void SetAcceleration(PhysicsVector accel)
440 { 440 {
441 this._acceleration = accel; 441 this._acceleration = accel;
442 } 442 }
443 443
444 public override void AddForce(PhysicsVector force) 444 public override void AddForce(PhysicsVector force)
445 { 445 {
446 446
447 } 447 }
448 448
449 public override void SetMomentum(PhysicsVector momentum) 449 public override void SetMomentum(PhysicsVector momentum)
450 { 450 {
451 451
452 } 452 }
453 453
454 454
455 } 455 }
456 456
457} 457}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
index ee10430..662b75a 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("RealPhysXplugin")] 36[assembly: AssemblyTitle("RealPhysXplugin")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("RealPhysXplugin")] 40[assembly: AssemblyProduct("RealPhysXplugin")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 4c82549..111d436 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -1,425 +1,425 @@
1/*/* 1/*/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Physics.Manager; 30using OpenSim.Physics.Manager;
31using PhysXWrapper; 31using PhysXWrapper;
32using Quaternion=Axiom.Math.Quaternion; 32using Quaternion=Axiom.Math.Quaternion;
33 33
34namespace OpenSim.Region.Physics.PhysXPlugin 34namespace OpenSim.Region.Physics.PhysXPlugin
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// Will be the PhysX plugin but for now will be a very basic physics engine 37 /// Will be the PhysX plugin but for now will be a very basic physics engine
38 /// </summary> 38 /// </summary>
39 public class PhysXPlugin : IPhysicsPlugin 39 public class PhysXPlugin : IPhysicsPlugin
40 { 40 {
41 private PhysXScene _mScene; 41 private PhysXScene _mScene;
42 42
43 public PhysXPlugin() 43 public PhysXPlugin()
44 { 44 {
45 45
46 } 46 }
47 47
48 public bool Init() 48 public bool Init()
49 { 49 {
50 return true; 50 return true;
51 } 51 }
52 52
53 public PhysicsScene GetScene() 53 public PhysicsScene GetScene()
54 { 54 {
55 if(_mScene == null) 55 if(_mScene == null)
56 { 56 {
57 _mScene = new PhysXScene(); 57 _mScene = new PhysXScene();
58 } 58 }
59 return(_mScene); 59 return(_mScene);
60 } 60 }
61 61
62 public string GetName() 62 public string GetName()
63 { 63 {
64 return("RealPhysX"); 64 return("RealPhysX");
65 } 65 }
66 66
67 public void Dispose() 67 public void Dispose()
68 { 68 {
69 69
70 } 70 }
71 } 71 }
72 72
73 public class PhysXScene :PhysicsScene 73 public class PhysXScene :PhysicsScene
74 { 74 {
75 private List<PhysXCharacter> _characters = new List<PhysXCharacter>(); 75 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
76 private List<PhysXPrim> _prims = new List<PhysXPrim>(); 76 private List<PhysXPrim> _prims = new List<PhysXPrim>();
77 private float[] _heightMap = null; 77 private float[] _heightMap = null;
78 private NxPhysicsSDK mySdk; 78 private NxPhysicsSDK mySdk;
79 private NxScene scene; 79 private NxScene scene;
80 80
81 public PhysXScene() 81 public PhysXScene()
82 { 82 {
83 mySdk = NxPhysicsSDK.CreateSDK(); 83 mySdk = NxPhysicsSDK.CreateSDK();
84 Console.WriteLine("Sdk created - now creating scene"); 84 Console.WriteLine("Sdk created - now creating scene");
85 scene = mySdk.CreateScene(); 85 scene = mySdk.CreateScene();
86 86
87 } 87 }
88 88
89 public override PhysicsActor AddAvatar(PhysicsVector position) 89 public override PhysicsActor AddAvatar(PhysicsVector position)
90 { 90 {
91 Vec3 pos = new Vec3(); 91 Vec3 pos = new Vec3();
92 pos.X = position.X; 92 pos.X = position.X;
93 pos.Y = position.Y; 93 pos.Y = position.Y;
94 pos.Z = position.Z; 94 pos.Z = position.Z;
95 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos)); 95 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
96 act.Position = position; 96 act.Position = position;
97 _characters.Add(act); 97 _characters.Add(act);
98 return act; 98 return act;
99 } 99 }
100 100
101 public override void RemoveAvatar(PhysicsActor actor) 101 public override void RemoveAvatar(PhysicsActor actor)
102 { 102 {
103 103
104 } 104 }
105 105
106 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 106 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
107 { 107 {
108 Vec3 pos = new Vec3(); 108 Vec3 pos = new Vec3();
109 pos.X = position.X; 109 pos.X = position.X;
110 pos.Y = position.Y; 110 pos.Y = position.Y;
111 pos.Z = position.Z; 111 pos.Z = position.Z;
112 Vec3 siz = new Vec3(); 112 Vec3 siz = new Vec3();
113 siz.X = size.X; 113 siz.X = size.X;
114 siz.Y = size.Y; 114 siz.Y = size.Y;
115 siz.Z = size.Z; 115 siz.Z = size.Z;
116 PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz)); 116 PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
117 _prims.Add(act); 117 _prims.Add(act);
118 return act; 118 return act;
119 } 119 }
120 public override void Simulate(float timeStep) 120 public override void Simulate(float timeStep)
121 { 121 {
122 try 122 try
123 { 123 {
124 foreach (PhysXCharacter actor in _characters) 124 foreach (PhysXCharacter actor in _characters)
125 { 125 {
126 actor.Move(timeStep); 126 actor.Move(timeStep);
127 } 127 }
128 scene.Simulate(timeStep); 128 scene.Simulate(timeStep);
129 scene.FetchResults(); 129 scene.FetchResults();
130 scene.UpdateControllers(); 130 scene.UpdateControllers();
131 131
132 foreach (PhysXCharacter actor in _characters) 132 foreach (PhysXCharacter actor in _characters)
133 { 133 {
134 actor.UpdatePosition(); 134 actor.UpdatePosition();
135 } 135 }
136 } 136 }
137 catch (Exception e) 137 catch (Exception e)
138 { 138 {
139 Console.WriteLine(e.Message); 139 Console.WriteLine(e.Message);
140 } 140 }
141 141
142 } 142 }
143 143
144 public override void GetResults() 144 public override void GetResults()
145 { 145 {
146 146
147 } 147 }
148 148
149 public override bool IsThreaded 149 public override bool IsThreaded
150 { 150 {
151 get 151 get
152 { 152 {
153 return(false); // for now we won't be multithreaded 153 return(false); // for now we won't be multithreaded
154 } 154 }
155 } 155 }
156 156
157 public override void SetTerrain(float[] heightMap) 157 public override void SetTerrain(float[] heightMap)
158 { 158 {
159 if (this._heightMap != null) 159 if (this._heightMap != null)
160 { 160 {
161 Console.WriteLine("PhysX - deleting old terrain"); 161 Console.WriteLine("PhysX - deleting old terrain");
162 this.scene.DeleteTerrain(); 162 this.scene.DeleteTerrain();
163 } 163 }
164 this._heightMap = heightMap; 164 this._heightMap = heightMap;
165 this.scene.AddTerrain(heightMap); 165 this.scene.AddTerrain(heightMap);
166 } 166 }
167 167
168 public override void DeleteTerrain() 168 public override void DeleteTerrain()
169 { 169 {
170 this.scene.DeleteTerrain(); 170 this.scene.DeleteTerrain();
171 } 171 }
172 } 172 }
173 173
174 public class PhysXCharacter : PhysicsActor 174 public class PhysXCharacter : PhysicsActor
175 { 175 {
176 private PhysicsVector _position; 176 private PhysicsVector _position;
177 private PhysicsVector _velocity; 177 private PhysicsVector _velocity;
178 private PhysicsVector _acceleration; 178 private PhysicsVector _acceleration;
179 private NxCharacter _character; 179 private NxCharacter _character;
180 private bool flying; 180 private bool flying;
181 private float gravityAccel; 181 private float gravityAccel;
182 182
183 public PhysXCharacter(NxCharacter character) 183 public PhysXCharacter(NxCharacter character)
184 { 184 {
185 _velocity = new PhysicsVector(); 185 _velocity = new PhysicsVector();
186 _position = new PhysicsVector(); 186 _position = new PhysicsVector();
187 _acceleration = new PhysicsVector(); 187 _acceleration = new PhysicsVector();
188 _character = character; 188 _character = character;
189 } 189 }
190 190
191 public override bool Flying 191 public override bool Flying
192 { 192 {
193 get 193 get
194 { 194 {
195 return flying; 195 return flying;
196 } 196 }
197 set 197 set
198 { 198 {
199 flying = value; 199 flying = value;
200 } 200 }
201 } 201 }
202 202
203 public override PhysicsVector Position 203 public override PhysicsVector Position
204 { 204 {
205 get 205 get
206 { 206 {
207 return _position; 207 return _position;
208 } 208 }
209 set 209 set
210 { 210 {
211 _position = value; 211 _position = value;
212 Vec3 ps = new Vec3(); 212 Vec3 ps = new Vec3();
213 ps.X = value.X; 213 ps.X = value.X;
214 ps.Y = value.Y; 214 ps.Y = value.Y;
215 ps.Z = value.Z; 215 ps.Z = value.Z;
216 this._character.Position = ps; 216 this._character.Position = ps;
217 } 217 }
218 } 218 }
219 219
220 public override PhysicsVector Velocity 220 public override PhysicsVector Velocity
221 { 221 {
222 get 222 get
223 { 223 {
224 return _velocity; 224 return _velocity;
225 } 225 }
226 set 226 set
227 { 227 {
228 _velocity = value; 228 _velocity = value;
229 } 229 }
230 } 230 }
231 231
232 public override bool Kinematic 232 public override bool Kinematic
233 { 233 {
234 get 234 get
235 { 235 {
236 return false; 236 return false;
237 } 237 }
238 set 238 set
239 { 239 {
240 240
241 } 241 }
242 } 242 }
243 243
244 public override Quaternion Orientation 244 public override Quaternion Orientation
245 { 245 {
246 get 246 get
247 { 247 {
248 return Quaternion.Identity; 248 return Quaternion.Identity;
249 } 249 }
250 set 250 set
251 { 251 {
252 252
253 } 253 }
254 } 254 }
255 255
256 public override PhysicsVector Acceleration 256 public override PhysicsVector Acceleration
257 { 257 {
258 get 258 get
259 { 259 {
260 return _acceleration; 260 return _acceleration;
261 } 261 }
262 262
263 } 263 }
264 public void SetAcceleration (PhysicsVector accel) 264 public void SetAcceleration (PhysicsVector accel)
265 { 265 {
266 this._acceleration = accel; 266 this._acceleration = accel;
267 } 267 }
268 268
269 public override void AddForce(PhysicsVector force) 269 public override void AddForce(PhysicsVector force)
270 { 270 {
271 271
272 } 272 }
273 273
274 public override void SetMomentum(PhysicsVector momentum) 274 public override void SetMomentum(PhysicsVector momentum)
275 { 275 {
276 276
277 } 277 }
278 278
279 public void Move(float timeStep) 279 public void Move(float timeStep)
280 { 280 {
281 Vec3 vec = new Vec3(); 281 Vec3 vec = new Vec3();
282 vec.X = this._velocity.X * timeStep; 282 vec.X = this._velocity.X * timeStep;
283 vec.Y = this._velocity.Y * timeStep; 283 vec.Y = this._velocity.Y * timeStep;
284 if(flying) 284 if(flying)
285 { 285 {
286 vec.Z = ( this._velocity.Z) * timeStep; 286 vec.Z = ( this._velocity.Z) * timeStep;
287 } 287 }
288 else 288 else
289 { 289 {
290 gravityAccel+= -9.8f; 290 gravityAccel+= -9.8f;
291 vec.Z = (gravityAccel + this._velocity.Z) * timeStep; 291 vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
292 } 292 }
293 int res = this._character.Move(vec); 293 int res = this._character.Move(vec);
294 if(res == 1) 294 if(res == 1)
295 { 295 {
296 gravityAccel = 0; 296 gravityAccel = 0;
297 } 297 }
298 } 298 }
299 299
300 public void UpdatePosition() 300 public void UpdatePosition()
301 { 301 {
302 Vec3 vec = this._character.Position; 302 Vec3 vec = this._character.Position;
303 this._position.X = vec.X; 303 this._position.X = vec.X;
304 this._position.Y = vec.Y; 304 this._position.Y = vec.Y;
305 this._position.Z = vec.Z; 305 this._position.Z = vec.Z;
306 } 306 }
307 } 307 }
308 308
309 public class PhysXPrim : PhysicsActor 309 public class PhysXPrim : PhysicsActor
310 { 310 {
311 private PhysicsVector _position; 311 private PhysicsVector _position;
312 private PhysicsVector _velocity; 312 private PhysicsVector _velocity;
313 private PhysicsVector _acceleration; 313 private PhysicsVector _acceleration;
314 private NxActor _prim; 314 private NxActor _prim;
315 315
316 public PhysXPrim(NxActor prim) 316 public PhysXPrim(NxActor prim)
317 { 317 {
318 _velocity = new PhysicsVector(); 318 _velocity = new PhysicsVector();
319 _position = new PhysicsVector(); 319 _position = new PhysicsVector();
320 _acceleration = new PhysicsVector(); 320 _acceleration = new PhysicsVector();
321 _prim = prim; 321 _prim = prim;
322 } 322 }
323 public override bool Flying 323 public override bool Flying
324 { 324 {
325 get 325 get
326 { 326 {
327 return false; //no flying prims for you 327 return false; //no flying prims for you
328 } 328 }
329 set 329 set
330 { 330 {
331 331
332 } 332 }
333 } 333 }
334 public override PhysicsVector Position 334 public override PhysicsVector Position
335 { 335 {
336 get 336 get
337 { 337 {
338 PhysicsVector pos = new PhysicsVector(); 338 PhysicsVector pos = new PhysicsVector();
339 Vec3 vec = this._prim.Position; 339 Vec3 vec = this._prim.Position;
340 pos.X = vec.X; 340 pos.X = vec.X;
341 pos.Y = vec.Y; 341 pos.Y = vec.Y;
342 pos.Z = vec.Z; 342 pos.Z = vec.Z;
343 return pos; 343 return pos;
344 344
345 } 345 }
346 set 346 set
347 { 347 {
348 PhysicsVector vec = value; 348 PhysicsVector vec = value;
349 Vec3 pos = new Vec3(); 349 Vec3 pos = new Vec3();
350 pos.X = vec.X; 350 pos.X = vec.X;
351 pos.Y = vec.Y; 351 pos.Y = vec.Y;
352 pos.Z = vec.Z; 352 pos.Z = vec.Z;
353 this._prim.Position = pos; 353 this._prim.Position = pos;
354 } 354 }
355 } 355 }
356 356
357 public override PhysicsVector Velocity 357 public override PhysicsVector Velocity
358 { 358 {
359 get 359 get
360 { 360 {
361 return _velocity; 361 return _velocity;
362 } 362 }
363 set 363 set
364 { 364 {
365 _velocity = value; 365 _velocity = value;
366 } 366 }
367 } 367 }
368 368
369 public override bool Kinematic 369 public override bool Kinematic
370 { 370 {
371 get 371 get
372 { 372 {
373 return this._prim.Kinematic; 373 return this._prim.Kinematic;
374 } 374 }
375 set 375 set
376 { 376 {
377 this._prim.Kinematic = value; 377 this._prim.Kinematic = value;
378 } 378 }
379 } 379 }
380 380
381 public override Quaternion Orientation 381 public override Quaternion Orientation
382 { 382 {
383 get 383 get
384 { 384 {
385 Quaternion res = new Quaternion(); 385 Quaternion res = new Quaternion();
386 PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); 386 PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
387 res.w = quat.W; 387 res.w = quat.W;
388 res.x = quat.X; 388 res.x = quat.X;
389 res.y = quat.Y; 389 res.y = quat.Y;
390 res.z = quat.Z; 390 res.z = quat.Z;
391 return res; 391 return res;
392 } 392 }
393 set 393 set
394 { 394 {
395 395
396 } 396 }
397 } 397 }
398 398
399 public override PhysicsVector Acceleration 399 public override PhysicsVector Acceleration
400 { 400 {
401 get 401 get
402 { 402 {
403 return _acceleration; 403 return _acceleration;
404 } 404 }
405 405
406 } 406 }
407 public void SetAcceleration (PhysicsVector accel) 407 public void SetAcceleration (PhysicsVector accel)
408 { 408 {
409 this._acceleration = accel; 409 this._acceleration = accel;
410 } 410 }
411 411
412 public override void AddForce(PhysicsVector force) 412 public override void AddForce(PhysicsVector force)
413 { 413 {
414 414
415 } 415 }
416 416
417 public override void SetMomentum(PhysicsVector momentum) 417 public override void SetMomentum(PhysicsVector momentum)
418 { 418 {
419 419
420 } 420 }
421 421
422 422
423 } 423 }
424 424
425} 425}
diff --git a/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
index f5da4c0..d6debed 100644
--- a/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Scripting/Properties/AssemblyInfo.cs
@@ -1,35 +1,35 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Scripting")] 8[assembly: AssemblyTitle("OpenSim.Scripting")]
9[assembly: AssemblyDescription("")] 9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")] 10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")] 11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Scripting")] 12[assembly: AssemblyProduct("OpenSim.Scripting")]
13[assembly: AssemblyCopyright("Copyright © 2007")] 13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
22// The following GUID is for the ID of the typelib if this project is exposed to COM 22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("61eae1ad-82aa-4c77-8bc5-b5a8c9522b18")] 23[assembly: Guid("61eae1ad-82aa-4c77-8bc5-b5a8c9522b18")]
24 24
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32// You can specify all the values or you can default the Revision and Build Numbers 32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below: 33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")] 34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")] 35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Scripting/Script.cs b/OpenSim/Region/Scripting/Script.cs
index 0f4af00..0551ea0 100644
--- a/OpenSim/Region/Scripting/Script.cs
+++ b/OpenSim/Region/Scripting/Script.cs
@@ -1,32 +1,32 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Framework.Console; 5using OpenSim.Framework.Console;
6using OpenSim.Framework; 6using OpenSim.Framework;
7using OpenSim.Region; 7using OpenSim.Region;
8using OpenSim.Region.Scenes; 8using OpenSim.Region.Scenes;
9 9
10namespace OpenSim.Scripting 10namespace OpenSim.Scripting
11{ 11{
12 public interface IScript 12 public interface IScript
13 { 13 {
14 void Initialise(ScriptInfo scriptInfo); 14 void Initialise(ScriptInfo scriptInfo);
15 } 15 }
16 16
17 public class TestScript : IScript 17 public class TestScript : IScript
18 { 18 {
19 ScriptInfo script; 19 ScriptInfo script;
20 20
21 public void Initialise(ScriptInfo scriptInfo) 21 public void Initialise(ScriptInfo scriptInfo)
22 { 22 {
23 script = scriptInfo; 23 script = scriptInfo;
24 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame); 24 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
25 } 25 }
26 26
27 void events_OnFrame() 27 void events_OnFrame()
28 { 28 {
29 script.logger.Verbose("Hello World!"); 29 script.logger.Verbose("Hello World!");
30 } 30 }
31 } 31 }
32} 32}
diff --git a/OpenSim/Region/Scripting/ScriptAccess.cs b/OpenSim/Region/Scripting/ScriptAccess.cs
index a9fede5..ce814a4 100644
--- a/OpenSim/Region/Scripting/ScriptAccess.cs
+++ b/OpenSim/Region/Scripting/ScriptAccess.cs
@@ -1,31 +1,31 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Region.Scenes; 5using OpenSim.Region.Scenes;
6using OpenSim.Framework.Console; 6using OpenSim.Framework.Console;
7 7
8namespace OpenSim.Scripting 8namespace OpenSim.Scripting
9{ 9{
10 /// <summary> 10 /// <summary>
11 /// Class which provides access to the world 11 /// Class which provides access to the world
12 /// </summary> 12 /// </summary>
13 public class ScriptInfo 13 public class ScriptInfo
14 { 14 {
15 // Reference to world.eventsManager provided for convenience 15 // Reference to world.eventsManager provided for convenience
16 public EventManager events; 16 public EventManager events;
17 17
18 // The main world 18 // The main world
19 public Scene world; 19 public Scene world;
20 20
21 // The console 21 // The console
22 public LogBase logger; 22 public LogBase logger;
23 23
24 public ScriptInfo(Scene scene) 24 public ScriptInfo(Scene scene)
25 { 25 {
26 world = scene; 26 world = scene;
27 events = world.eventManager; 27 events = world.eventManager;
28 logger = OpenSim.Framework.Console.MainLog.Instance; 28 logger = OpenSim.Framework.Console.MainLog.Instance;
29 } 29 }
30 } 30 }
31} 31}
diff --git a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
index 39ba6e4..0a88594 100644
--- a/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
+++ b/OpenSim/Region/Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
@@ -1,112 +1,112 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29// BDB Support 29// BDB Support
30// Apparently broken on Mono 30// Apparently broken on Mono
31 31
32using BerkeleyDb; 32using BerkeleyDb;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36 36
37namespace OpenSim.Region.Storage.LocalStorageBDB 37namespace OpenSim.Region.Storage.LocalStorageBDB
38{ 38{
39 public class BDBLocalStorage : ILocalStorage 39 public class BDBLocalStorage : ILocalStorage
40 { 40 {
41 const string simDbName = "localsim.db"; 41 const string simDbName = "localsim.db";
42 42
43 DbHash sim; 43 DbHash sim;
44 Db DB; 44 Db DB;
45 //BEFormatter formatter; 45 //BEFormatter formatter;
46 46
47 public BDBLocalStorage() 47 public BDBLocalStorage()
48 { 48 {
49 DB = new Db(DbCreateFlags.None); 49 DB = new Db(DbCreateFlags.None);
50 sim = (DbHash)DB.Open(null, simDbName, null, DbType.Hash, Db.OpenFlags.Create, 0); 50 sim = (DbHash)DB.Open(null, simDbName, null, DbType.Hash, Db.OpenFlags.Create, 0);
51 //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0); 51 //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0);
52 } 52 }
53 53
54 public void Initialise(string file) 54 public void Initialise(string file)
55 { 55 {
56 // Blank 56 // Blank
57 } 57 }
58 58
59 public void StorePrim(PrimData prim) 59 public void StorePrim(PrimData prim)
60 { 60 {
61 DbEntry key = new DbEntry(); 61 DbEntry key = new DbEntry();
62 DbEntry data = new DbEntry(); 62 DbEntry data = new DbEntry();
63 lock (sim) 63 lock (sim)
64 { 64 {
65 sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit); 65 sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit);
66 } 66 }
67 } 67 }
68 public void RemovePrim(LLUUID primID) 68 public void RemovePrim(LLUUID primID)
69 { 69 {
70 70
71 } 71 }
72 public void LoadPrimitives(ILocalStorageReceiver receiver) 72 public void LoadPrimitives(ILocalStorageReceiver receiver)
73 { 73 {
74 74
75 } 75 }
76 public float[] LoadWorld() 76 public float[] LoadWorld()
77 { 77 {
78 return new float[65536]; 78 return new float[65536];
79 } 79 }
80 public void SaveMap(float[] heightmap) 80 public void SaveMap(float[] heightmap)
81 { 81 {
82 82
83 } 83 }
84 84
85 public void SaveParcels(ParcelData[] parcel_data) 85 public void SaveParcels(ParcelData[] parcel_data)
86 { 86 {
87 } 87 }
88 88
89 public void SaveParcel(ParcelData parcel) 89 public void SaveParcel(ParcelData parcel)
90 { 90 {
91 } 91 }
92 92
93 public void RemoveParcel(ParcelData parcel) 93 public void RemoveParcel(ParcelData parcel)
94 { 94 {
95 } 95 }
96 96
97 public void RemoveAllParcels() 97 public void RemoveAllParcels()
98 { 98 {
99 } 99 }
100 100
101 public void LoadParcels(ILocalStorageParcelReceiver recv) 101 public void LoadParcels(ILocalStorageParcelReceiver recv)
102 { 102 {
103 recv.NoParcelDataFromStorage(); 103 recv.NoParcelDataFromStorage();
104 } 104 }
105 105
106 public void ShutDown() 106 public void ShutDown()
107 { 107 {
108 sim.GetDb().Close(); 108 sim.GetDb().Close();
109 DB.Close(); 109 DB.Close();
110 } 110 }
111 } 111 }
112} \ No newline at end of file 112} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
index 4463ac9..a3aac18 100644
--- a/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("Db4LocalStorage")] 36[assembly: AssemblyTitle("Db4LocalStorage")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("Db4LocalStorage")] 40[assembly: AssemblyProduct("Db4LocalStorage")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
index 8214bc8..8d9f473 100644
--- a/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -1,267 +1,267 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using Db4objects.Db4o; 29using Db4objects.Db4o;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework.Console; 31using OpenSim.Framework.Console;
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34 34
35namespace OpenSim.Region.Storage.LocalStorageDb4o 35namespace OpenSim.Region.Storage.LocalStorageDb4o
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// 38 ///
39 /// </summary> 39 /// </summary>
40 public class Db4LocalStorage : ILocalStorage 40 public class Db4LocalStorage : ILocalStorage
41 { 41 {
42 private IObjectContainer db; 42 private IObjectContainer db;
43 private string datastore; 43 private string datastore;
44 44
45 public Db4LocalStorage() 45 public Db4LocalStorage()
46 { 46 {
47 47
48 } 48 }
49 49
50 public void Initialise(string dfile) 50 public void Initialise(string dfile)
51 { 51 {
52 MainLog.Instance.Warn("Db4LocalStorage Opening " + dfile); 52 MainLog.Instance.Warn("Db4LocalStorage Opening " + dfile);
53 datastore = dfile; 53 datastore = dfile;
54 try 54 try
55 { 55 {
56 db = Db4oFactory.OpenFile(datastore); 56 db = Db4oFactory.OpenFile(datastore);
57 MainLog.Instance.Verbose("Db4LocalStorage creation"); 57 MainLog.Instance.Verbose("Db4LocalStorage creation");
58 } 58 }
59 catch (Exception e) 59 catch (Exception e)
60 { 60 {
61 db.Close(); 61 db.Close();
62 MainLog.Instance.Warn("Db4LocalStorage :Constructor - Exception occured"); 62 MainLog.Instance.Warn("Db4LocalStorage :Constructor - Exception occured");
63 MainLog.Instance.Warn(e.ToString()); 63 MainLog.Instance.Warn(e.ToString());
64 } 64 }
65 } 65 }
66 66
67 public void StorePrim(PrimData prim) 67 public void StorePrim(PrimData prim)
68 { 68 {
69 IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID)); 69 IObjectSet result = db.Query(new UUIDPrimQuery(prim.FullID));
70 if (result.Count > 0) 70 if (result.Count > 0)
71 { 71 {
72 //prim already in storage 72 //prim already in storage
73 //so update it 73 //so update it
74 PrimData found = (PrimData)result.Next(); 74 PrimData found = (PrimData)result.Next();
75 found.PathBegin = prim.PathBegin; 75 found.PathBegin = prim.PathBegin;
76 found.PathCurve = prim.PathCurve; 76 found.PathCurve = prim.PathCurve;
77 found.PathEnd = prim.PathEnd; 77 found.PathEnd = prim.PathEnd;
78 found.PathRadiusOffset = prim.PathRadiusOffset; 78 found.PathRadiusOffset = prim.PathRadiusOffset;
79 found.PathRevolutions = prim.PathRevolutions; 79 found.PathRevolutions = prim.PathRevolutions;
80 found.PathScaleX = prim.PathScaleX; 80 found.PathScaleX = prim.PathScaleX;
81 found.PathScaleY = prim.PathScaleY; 81 found.PathScaleY = prim.PathScaleY;
82 found.PathShearX = prim.PathShearX; 82 found.PathShearX = prim.PathShearX;
83 found.PathShearY = prim.PathShearY; 83 found.PathShearY = prim.PathShearY;
84 found.PathSkew = prim.PathSkew; 84 found.PathSkew = prim.PathSkew;
85 found.PathTaperX = prim.PathTaperX; 85 found.PathTaperX = prim.PathTaperX;
86 found.PathTaperY = prim.PathTaperY; 86 found.PathTaperY = prim.PathTaperY;
87 found.PathTwist = prim.PathTwist; 87 found.PathTwist = prim.PathTwist;
88 found.PathTwistBegin = prim.PathTwistBegin; 88 found.PathTwistBegin = prim.PathTwistBegin;
89 found.PCode = prim.PCode; 89 found.PCode = prim.PCode;
90 found.ProfileBegin = prim.ProfileBegin; 90 found.ProfileBegin = prim.ProfileBegin;
91 found.ProfileCurve = prim.ProfileCurve; 91 found.ProfileCurve = prim.ProfileCurve;
92 found.ProfileEnd = prim.ProfileEnd; 92 found.ProfileEnd = prim.ProfileEnd;
93 found.ProfileHollow = prim.ProfileHollow; 93 found.ProfileHollow = prim.ProfileHollow;
94 found.Position = prim.Position; 94 found.Position = prim.Position;
95 found.Rotation = prim.Rotation; 95 found.Rotation = prim.Rotation;
96 found.TextureEntry = prim.TextureEntry; 96 found.TextureEntry = prim.TextureEntry;
97 db.Set(found); 97 db.Set(found);
98 db.Commit(); 98 db.Commit();
99 } 99 }
100 else 100 else
101 { 101 {
102 //not in storage 102 //not in storage
103 db.Set(prim); 103 db.Set(prim);
104 db.Commit(); 104 db.Commit();
105 } 105 }
106 } 106 }
107 107
108 public void RemovePrim(LLUUID primID) 108 public void RemovePrim(LLUUID primID)
109 { 109 {
110 IObjectSet result = db.Query(new UUIDPrimQuery(primID)); 110 IObjectSet result = db.Query(new UUIDPrimQuery(primID));
111 if (result.Count > 0) 111 if (result.Count > 0)
112 { 112 {
113 PrimData found = (PrimData)result.Next(); 113 PrimData found = (PrimData)result.Next();
114 db.Delete(found); 114 db.Delete(found);
115 } 115 }
116 } 116 }
117 117
118 118
119 public void LoadPrimitives(ILocalStorageReceiver receiver) 119 public void LoadPrimitives(ILocalStorageReceiver receiver)
120 { 120 {
121 IObjectSet result = db.Get(typeof(PrimData)); 121 IObjectSet result = db.Get(typeof(PrimData));
122 MainLog.Instance.Verbose("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is " + result.Count); 122 MainLog.Instance.Verbose("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is " + result.Count);
123 foreach (PrimData prim in result) 123 foreach (PrimData prim in result)
124 { 124 {
125 receiver.PrimFromStorage(prim); 125 receiver.PrimFromStorage(prim);
126 } 126 }
127 } 127 }
128 128
129 public float[] LoadWorld() 129 public float[] LoadWorld()
130 { 130 {
131 MainLog.Instance.Verbose("LoadWorld() - Loading world...."); 131 MainLog.Instance.Verbose("LoadWorld() - Loading world....");
132 float[] heightmap = null; 132 float[] heightmap = null;
133 MainLog.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB"); 133 MainLog.Instance.Verbose("LoadWorld() - Looking for a heightmap in local DB");
134 IObjectSet world_result = db.Get(typeof(MapStorage)); 134 IObjectSet world_result = db.Get(typeof(MapStorage));
135 if (world_result.Count > 0) 135 if (world_result.Count > 0)
136 { 136 {
137 MainLog.Instance.Verbose("LoadWorld() - Found a heightmap in local database, loading"); 137 MainLog.Instance.Verbose("LoadWorld() - Found a heightmap in local database, loading");
138 MapStorage map = (MapStorage)world_result.Next(); 138 MapStorage map = (MapStorage)world_result.Next();
139 //blank.LandMap = map.Map; 139 //blank.LandMap = map.Map;
140 heightmap = map.Map; 140 heightmap = map.Map;
141 } 141 }
142 return heightmap; 142 return heightmap;
143 } 143 }
144 144
145 public void SaveMap(float[] heightmap) 145 public void SaveMap(float[] heightmap)
146 { 146 {
147 IObjectSet world_result = db.Get(typeof(MapStorage)); 147 IObjectSet world_result = db.Get(typeof(MapStorage));
148 if (world_result.Count > 0) 148 if (world_result.Count > 0)
149 { 149 {
150 MainLog.Instance.Verbose("SaveWorld() - updating saved copy of heightmap in local database"); 150 MainLog.Instance.Verbose("SaveWorld() - updating saved copy of heightmap in local database");
151 MapStorage map = (MapStorage)world_result.Next(); 151 MapStorage map = (MapStorage)world_result.Next();
152 db.Delete(map); 152 db.Delete(map);
153 } 153 }
154 MapStorage map1 = new MapStorage(); 154 MapStorage map1 = new MapStorage();
155 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap; 155 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
156 db.Set(map1); 156 db.Set(map1);
157 db.Commit(); 157 db.Commit();
158 } 158 }
159 159
160 public void SaveParcel(ParcelData parcel) 160 public void SaveParcel(ParcelData parcel)
161 { 161 {
162 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); 162 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
163 if (result.Count > 0) 163 if (result.Count > 0)
164 { 164 {
165 //Old Parcel 165 //Old Parcel
166 ParcelData updateParcel = (ParcelData)result.Next(); 166 ParcelData updateParcel = (ParcelData)result.Next();
167 updateParcel.AABBMax = parcel.AABBMax; 167 updateParcel.AABBMax = parcel.AABBMax;
168 updateParcel.AABBMin = parcel.AABBMin; 168 updateParcel.AABBMin = parcel.AABBMin;
169 updateParcel.area = parcel.area; 169 updateParcel.area = parcel.area;
170 updateParcel.auctionID = parcel.auctionID; 170 updateParcel.auctionID = parcel.auctionID;
171 updateParcel.authBuyerID = parcel.authBuyerID; 171 updateParcel.authBuyerID = parcel.authBuyerID;
172 updateParcel.category = parcel.category; 172 updateParcel.category = parcel.category;
173 updateParcel.claimDate = parcel.claimDate; 173 updateParcel.claimDate = parcel.claimDate;
174 updateParcel.claimPrice = parcel.claimPrice; 174 updateParcel.claimPrice = parcel.claimPrice;
175 updateParcel.groupID = parcel.groupID; 175 updateParcel.groupID = parcel.groupID;
176 updateParcel.groupPrims = parcel.groupPrims; 176 updateParcel.groupPrims = parcel.groupPrims;
177 updateParcel.isGroupOwned = parcel.isGroupOwned; 177 updateParcel.isGroupOwned = parcel.isGroupOwned;
178 updateParcel.landingType = parcel.landingType; 178 updateParcel.landingType = parcel.landingType;
179 updateParcel.mediaAutoScale = parcel.mediaAutoScale; 179 updateParcel.mediaAutoScale = parcel.mediaAutoScale;
180 updateParcel.mediaID = parcel.mediaID; 180 updateParcel.mediaID = parcel.mediaID;
181 updateParcel.mediaURL = parcel.mediaURL; 181 updateParcel.mediaURL = parcel.mediaURL;
182 updateParcel.musicURL = parcel.musicURL; 182 updateParcel.musicURL = parcel.musicURL;
183 updateParcel.localID = parcel.localID; 183 updateParcel.localID = parcel.localID;
184 updateParcel.ownerID = parcel.ownerID; 184 updateParcel.ownerID = parcel.ownerID;
185 updateParcel.passHours = parcel.passHours; 185 updateParcel.passHours = parcel.passHours;
186 updateParcel.passPrice = parcel.passPrice; 186 updateParcel.passPrice = parcel.passPrice;
187 updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone(); 187 updateParcel.parcelBitmapByteArray = (byte[])parcel.parcelBitmapByteArray.Clone();
188 updateParcel.parcelDesc = parcel.parcelDesc; 188 updateParcel.parcelDesc = parcel.parcelDesc;
189 updateParcel.parcelFlags = parcel.parcelFlags; 189 updateParcel.parcelFlags = parcel.parcelFlags;
190 updateParcel.parcelName = parcel.parcelName; 190 updateParcel.parcelName = parcel.parcelName;
191 updateParcel.parcelStatus = parcel.parcelStatus; 191 updateParcel.parcelStatus = parcel.parcelStatus;
192 updateParcel.salePrice = parcel.salePrice; 192 updateParcel.salePrice = parcel.salePrice;
193 updateParcel.snapshotID = parcel.snapshotID; 193 updateParcel.snapshotID = parcel.snapshotID;
194 updateParcel.userLocation = parcel.userLocation; 194 updateParcel.userLocation = parcel.userLocation;
195 updateParcel.userLookAt = parcel.userLookAt; 195 updateParcel.userLookAt = parcel.userLookAt;
196 196
197 db.Set(updateParcel); 197 db.Set(updateParcel);
198 } 198 }
199 else 199 else
200 { 200 {
201 db.Set(parcel); 201 db.Set(parcel);
202 } 202 }
203 db.Commit(); 203 db.Commit();
204 } 204 }
205 205
206 public void SaveParcels(ParcelData[] parcel_data) 206 public void SaveParcels(ParcelData[] parcel_data)
207 { 207 {
208 MainLog.Instance.Notice("Parcel Backup: Saving Parcels..."); 208 MainLog.Instance.Notice("Parcel Backup: Saving Parcels...");
209 int i; 209 int i;
210 for (i = 0; i < parcel_data.GetLength(0); i++) 210 for (i = 0; i < parcel_data.GetLength(0); i++)
211 { 211 {
212 212
213 SaveParcel(parcel_data[i]); 213 SaveParcel(parcel_data[i]);
214 214
215 } 215 }
216 MainLog.Instance.Notice("Parcel Backup: Parcel Save Complete"); 216 MainLog.Instance.Notice("Parcel Backup: Parcel Save Complete");
217 } 217 }
218 218
219 public void RemoveParcel(ParcelData parcel) 219 public void RemoveParcel(ParcelData parcel)
220 { 220 {
221 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID)); 221 IObjectSet result = db.Query(new UUIDParcelQuery(parcel.globalID));
222 if (result.Count > 0) 222 if (result.Count > 0)
223 { 223 {
224 db.Delete(result[0]); 224 db.Delete(result[0]);
225 } 225 }
226 db.Commit(); 226 db.Commit();
227 } 227 }
228 public void RemoveAllParcels() 228 public void RemoveAllParcels()
229 { 229 {
230 MainLog.Instance.Notice("Parcel Backup: Removing all parcels..."); 230 MainLog.Instance.Notice("Parcel Backup: Removing all parcels...");
231 IObjectSet result = db.Get(typeof(ParcelData)); 231 IObjectSet result = db.Get(typeof(ParcelData));
232 if (result.Count > 0) 232 if (result.Count > 0)
233 { 233 {
234 foreach (ParcelData parcelData in result) 234 foreach (ParcelData parcelData in result)
235 { 235 {
236 RemoveParcel(parcelData); 236 RemoveParcel(parcelData);
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 public void LoadParcels(ILocalStorageParcelReceiver recv) 241 public void LoadParcels(ILocalStorageParcelReceiver recv)
242 { 242 {
243 MainLog.Instance.Notice("Parcel Backup: Loading Parcels..."); 243 MainLog.Instance.Notice("Parcel Backup: Loading Parcels...");
244 IObjectSet result = db.Get(typeof(ParcelData)); 244 IObjectSet result = db.Get(typeof(ParcelData));
245 if (result.Count > 0) 245 if (result.Count > 0)
246 { 246 {
247 MainLog.Instance.Notice("Parcel Backup: Parcels exist in database."); 247 MainLog.Instance.Notice("Parcel Backup: Parcels exist in database.");
248 foreach (ParcelData parcelData in result) 248 foreach (ParcelData parcelData in result)
249 { 249 {
250 250
251 recv.ParcelFromStorage(parcelData); 251 recv.ParcelFromStorage(parcelData);
252 } 252 }
253 } 253 }
254 else 254 else
255 { 255 {
256 MainLog.Instance.Notice("Parcel Backup: No parcels exist. Creating basic parcel."); 256 MainLog.Instance.Notice("Parcel Backup: No parcels exist. Creating basic parcel.");
257 recv.NoParcelDataFromStorage(); 257 recv.NoParcelDataFromStorage();
258 } 258 }
259 MainLog.Instance.Notice("Parcel Backup: Parcels Restored"); 259 MainLog.Instance.Notice("Parcel Backup: Parcels Restored");
260 } 260 }
261 public void ShutDown() 261 public void ShutDown()
262 { 262 {
263 db.Commit(); 263 db.Commit();
264 db.Close(); 264 db.Close();
265 } 265 }
266 } 266 }
267} \ No newline at end of file 267} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
index ec82d02..3a5dd19 100644
--- a/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/MapStorage.cs
@@ -1,39 +1,39 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28namespace OpenSim.Region.Storage.LocalStorageDb4o 28namespace OpenSim.Region.Storage.LocalStorageDb4o
29{ 29{
30 public class MapStorage 30 public class MapStorage
31 { 31 {
32 public float[] Map; 32 public float[] Map;
33 33
34 public MapStorage() 34 public MapStorage()
35 { 35 {
36 36
37 } 37 }
38 } 38 }
39} \ No newline at end of file 39} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
index 6e6768c..debaa88 100644
--- a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDParcelQuery.cs
@@ -1,47 +1,47 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using Db4objects.Db4o.Query; 28using Db4objects.Db4o.Query;
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Framework.Types; 30using OpenSim.Framework.Types;
31 31
32namespace OpenSim.Region.Storage.LocalStorageDb4o 32namespace OpenSim.Region.Storage.LocalStorageDb4o
33{ 33{
34 public class UUIDParcelQuery : Predicate 34 public class UUIDParcelQuery : Predicate
35 { 35 {
36 private LLUUID globalIDSearch; 36 private LLUUID globalIDSearch;
37 37
38 public UUIDParcelQuery(LLUUID find) 38 public UUIDParcelQuery(LLUUID find)
39 { 39 {
40 globalIDSearch = find; 40 globalIDSearch = find;
41 } 41 }
42 public bool Match(ParcelData parcel) 42 public bool Match(ParcelData parcel)
43 { 43 {
44 return (parcel.globalID == globalIDSearch); 44 return (parcel.globalID == globalIDSearch);
45 } 45 }
46 } 46 }
47} 47}
diff --git a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
index eb309cb..d5077ff 100644
--- a/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
+++ b/OpenSim/Region/Storage/LocalStorageDb4o/UUIDPrimQuery.cs
@@ -1,47 +1,47 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using Db4objects.Db4o.Query; 28using Db4objects.Db4o.Query;
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Framework.Types; 30using OpenSim.Framework.Types;
31 31
32namespace OpenSim.Region.Storage.LocalStorageDb4o 32namespace OpenSim.Region.Storage.LocalStorageDb4o
33{ 33{
34 public class UUIDPrimQuery : Predicate 34 public class UUIDPrimQuery : Predicate
35 { 35 {
36 private LLUUID _findID; 36 private LLUUID _findID;
37 37
38 public UUIDPrimQuery(LLUUID find) 38 public UUIDPrimQuery(LLUUID find)
39 { 39 {
40 _findID = find; 40 _findID = find;
41 } 41 }
42 public bool Match(PrimData prim) 42 public bool Match(PrimData prim)
43 { 43 {
44 return (prim.FullID == _findID); 44 return (prim.FullID == _findID);
45 } 45 }
46 } 46 }
47} 47}
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
index 7bc1cc5..6bbaf0f 100644
--- a/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
@@ -1,60 +1,60 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// General Information about an assembly is controlled through the following 30// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information 31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly. 32// associated with an assembly.
33[assembly: AssemblyTitle("OpenSim.Region.Storage.LocalStorageSQLite")] 33[assembly: AssemblyTitle("OpenSim.Region.Storage.LocalStorageSQLite")]
34[assembly: AssemblyDescription("")] 34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")] 35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")] 36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenSim.Region.Storage.LocalStorageSQLite")] 37[assembly: AssemblyProduct("OpenSim.Region.Storage.LocalStorageSQLite")]
38[assembly: AssemblyCopyright("Copyright © 2007")] 38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")] 39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")] 40[assembly: AssemblyCulture("")]
41 41
42// Setting ComVisible to false makes the types in this assembly not visible 42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from 43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type. 44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)] 45[assembly: ComVisible(false)]
46 46
47// The following GUID is for the ID of the typelib if this project is exposed to COM 47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")] 48[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")]
49 49
50// Version information for an assembly consists of the following four values: 50// Version information for an assembly consists of the following four values:
51// 51//
52// Major Version 52// Major Version
53// Minor Version 53// Minor Version
54// Build Number 54// Build Number
55// Revision 55// Revision
56// 56//
57// You can specify all the values or you can default the Revision and Build Numbers 57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below: 58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")] 59[assembly: AssemblyVersion("1.0.0.0")]
60[assembly: AssemblyFileVersion("1.0.0.0")] 60[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
index 9900a98..599ff6c 100644
--- a/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
+++ b/OpenSim/Region/Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
@@ -1,198 +1,198 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29// SQLite Support 29// SQLite Support
30// A bad idea, but the IRC people told me to! 30// A bad idea, but the IRC people told me to!
31 31
32using System; 32using System;
33using System.Data; 33using System.Data;
34using System.Data.SQLite; 34using System.Data.SQLite;
35using libsecondlife; 35using libsecondlife;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Interfaces; 37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types; 38using OpenSim.Framework.Types;
39 39
40namespace OpenSim.Region.Storage.LocalStorageSQLite 40namespace OpenSim.Region.Storage.LocalStorageSQLite
41{ 41{
42 public class SQLiteLocalStorage : ILocalStorage 42 public class SQLiteLocalStorage : ILocalStorage
43 { 43 {
44 IDbConnection db; 44 IDbConnection db;
45 45
46 public SQLiteLocalStorage() 46 public SQLiteLocalStorage()
47 { 47 {
48 try 48 try
49 { 49 {
50 string connectionstring = "URI=file:localsim.sdb"; 50 string connectionstring = "URI=file:localsim.sdb";
51 db = (IDbConnection)new SQLiteConnection(connectionstring); 51 db = (IDbConnection)new SQLiteConnection(connectionstring);
52 db.Open(); 52 db.Open();
53 } 53 }
54 catch (Exception e) 54 catch (Exception e)
55 { 55 {
56 db.Close(); 56 db.Close();
57 MainLog.Instance.Warn("SQLiteLocalStorage :Constructor - Exception occured"); 57 MainLog.Instance.Warn("SQLiteLocalStorage :Constructor - Exception occured");
58 MainLog.Instance.Warn(e.ToString()); 58 MainLog.Instance.Warn(e.ToString());
59 } 59 }
60 } 60 }
61 61
62 public void Initialise(string file) 62 public void Initialise(string file)
63 { 63 {
64 // Blank 64 // Blank
65 } 65 }
66 66
67 public void StorePrim(PrimData prim) 67 public void StorePrim(PrimData prim)
68 { 68 {
69 IDbCommand cmd = db.CreateCommand(); 69 IDbCommand cmd = db.CreateCommand();
70 70
71 //SECURITY WARNING: 71 //SECURITY WARNING:
72 // These parameters wont produce SQL injections since they are all integer based, however. 72 // These parameters wont produce SQL injections since they are all integer based, however.
73 // if inserting strings such as name or description, you will need to use appropriate 73 // if inserting strings such as name or description, you will need to use appropriate
74 // measures to prevent SQL injection (although the value of SQL injection in this is limited). 74 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
75 75
76 string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) "; 76 string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) ";
77 sql += "VALUES ("; 77 sql += "VALUES (";
78 sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW! 78 sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW!
79 sql += "\"" + prim.PCode.ToString() + "\","; 79 sql += "\"" + prim.PCode.ToString() + "\",";
80 sql += "\"" + prim.PathBegin.ToString() + "\","; 80 sql += "\"" + prim.PathBegin.ToString() + "\",";
81 sql += "\"" + prim.PathEnd.ToString() + "\","; 81 sql += "\"" + prim.PathEnd.ToString() + "\",";
82 sql += "\"" + prim.PathScaleX.ToString() + "\","; 82 sql += "\"" + prim.PathScaleX.ToString() + "\",";
83 sql += "\"" + prim.PathScaleY.ToString() + "\","; 83 sql += "\"" + prim.PathScaleY.ToString() + "\",";
84 sql += "\"" + prim.PathShearX.ToString() + "\","; 84 sql += "\"" + prim.PathShearX.ToString() + "\",";
85 sql += "\"" + prim.PathShearY.ToString() + "\","; 85 sql += "\"" + prim.PathShearY.ToString() + "\",";
86 sql += "\"" + prim.PathSkew.ToString() + "\","; 86 sql += "\"" + prim.PathSkew.ToString() + "\",";
87 sql += "\"" + prim.ProfileBegin.ToString() + "\","; 87 sql += "\"" + prim.ProfileBegin.ToString() + "\",";
88 sql += "\"" + prim.ProfileEnd.ToString() + "\","; 88 sql += "\"" + prim.ProfileEnd.ToString() + "\",";
89 sql += "\"" + prim.Scale.ToString() + "\","; 89 sql += "\"" + prim.Scale.ToString() + "\",";
90 sql += "\"" + prim.PathCurve.ToString() + "\","; 90 sql += "\"" + prim.PathCurve.ToString() + "\",";
91 sql += "\"" + prim.ProfileCurve.ToString() + "\","; 91 sql += "\"" + prim.ProfileCurve.ToString() + "\",";
92 sql += "\"" + prim.ParentID.ToString() + "\","; 92 sql += "\"" + prim.ParentID.ToString() + "\",";
93 sql += "\"" + prim.ProfileHollow.ToString() + "\","; 93 sql += "\"" + prim.ProfileHollow.ToString() + "\",";
94 sql += "\"" + prim.PathRadiusOffset.ToString() + "\","; 94 sql += "\"" + prim.PathRadiusOffset.ToString() + "\",";
95 sql += "\"" + prim.PathRevolutions.ToString() + "\","; 95 sql += "\"" + prim.PathRevolutions.ToString() + "\",";
96 sql += "\"" + prim.PathTaperX.ToString() + "\","; 96 sql += "\"" + prim.PathTaperX.ToString() + "\",";
97 sql += "\"" + prim.PathTaperY.ToString() + "\","; 97 sql += "\"" + prim.PathTaperY.ToString() + "\",";
98 sql += "\"" + prim.PathTwist.ToString() + "\","; 98 sql += "\"" + prim.PathTwist.ToString() + "\",";
99 sql += "\"" + prim.PathTwistBegin.ToString() + "\","; 99 sql += "\"" + prim.PathTwistBegin.ToString() + "\",";
100 sql += "\"" + prim.TextureEntry.ToString() + "\","; 100 sql += "\"" + prim.TextureEntry.ToString() + "\",";
101 sql += "\"" + prim.CreationDate.ToString() + "\","; 101 sql += "\"" + prim.CreationDate.ToString() + "\",";
102 sql += "\"" + prim.OwnerMask.ToString() + "\","; 102 sql += "\"" + prim.OwnerMask.ToString() + "\",";
103 sql += "\"" + prim.NextOwnerMask.ToString() + "\","; 103 sql += "\"" + prim.NextOwnerMask.ToString() + "\",";
104 sql += "\"" + prim.GroupMask.ToString() + "\","; 104 sql += "\"" + prim.GroupMask.ToString() + "\",";
105 sql += "\"" + prim.EveryoneMask.ToString() + "\","; 105 sql += "\"" + prim.EveryoneMask.ToString() + "\",";
106 sql += "\"" + prim.BaseMask.ToString() + "\","; 106 sql += "\"" + prim.BaseMask.ToString() + "\",";
107 sql += "\"" + prim.Position.ToString() + "\","; 107 sql += "\"" + prim.Position.ToString() + "\",";
108 sql += "\"" + prim.Rotation.ToString() + "\","; 108 sql += "\"" + prim.Rotation.ToString() + "\",";
109 sql += "\"" + prim.LocalID.ToString() + "\","; 109 sql += "\"" + prim.LocalID.ToString() + "\",";
110 sql += "\"" + prim.FullID.ToString() + "\")"; 110 sql += "\"" + prim.FullID.ToString() + "\")";
111 111
112 cmd.CommandText = sql; 112 cmd.CommandText = sql;
113 113
114 try 114 try
115 { 115 {
116 cmd.ExecuteNonQuery(); 116 cmd.ExecuteNonQuery();
117 } 117 }
118 catch (Exception e) 118 catch (Exception e)
119 { 119 {
120 MainLog.Instance.Warn("SQLiteLocalStorage :StorePrim - Exception occured"); 120 MainLog.Instance.Warn("SQLiteLocalStorage :StorePrim - Exception occured");
121 MainLog.Instance.Warn(e.ToString()); 121 MainLog.Instance.Warn(e.ToString());
122 } 122 }
123 123
124 cmd.Dispose(); 124 cmd.Dispose();
125 cmd = null; 125 cmd = null;
126 } 126 }
127 127
128 public void RemovePrim(LLUUID primID) 128 public void RemovePrim(LLUUID primID)
129 { 129 {
130 IDbCommand cmd = db.CreateCommand(); 130 IDbCommand cmd = db.CreateCommand();
131 131
132 //SECURITY WARNING: 132 //SECURITY WARNING:
133 // These parameters wont produce SQL injections since they are all integer based, however. 133 // These parameters wont produce SQL injections since they are all integer based, however.
134 // if inserting strings such as name or description, you will need to use appropriate 134 // if inserting strings such as name or description, you will need to use appropriate
135 // measures to prevent SQL injection (although the value of SQL injection in this is limited). 135 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
136 136
137 string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\""; 137 string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\"";
138 138
139 cmd.CommandText = sql; 139 cmd.CommandText = sql;
140 140
141 try 141 try
142 { 142 {
143 cmd.ExecuteNonQuery(); 143 cmd.ExecuteNonQuery();
144 } 144 }
145 catch (Exception e) 145 catch (Exception e)
146 { 146 {
147 MainLog.Instance.Warn("SQLiteLocalStorage :RemovePrim - Exception occured"); 147 MainLog.Instance.Warn("SQLiteLocalStorage :RemovePrim - Exception occured");
148 MainLog.Instance.Warn(e.ToString()); 148 MainLog.Instance.Warn(e.ToString());
149 } 149 }
150 150
151 cmd.Dispose(); 151 cmd.Dispose();
152 cmd = null; 152 cmd = null;
153 } 153 }
154 154
155 public void LoadPrimitives(ILocalStorageReceiver receiver) 155 public void LoadPrimitives(ILocalStorageReceiver receiver)
156 { 156 {
157 157
158 } 158 }
159 159
160 public float[] LoadWorld() 160 public float[] LoadWorld()
161 { 161 {
162 return new float[65536]; 162 return new float[65536];
163 } 163 }
164 164
165 public void SaveMap(float[] heightmap) 165 public void SaveMap(float[] heightmap)
166 { 166 {
167 167
168 } 168 }
169 169
170 public void SaveParcels(ParcelData[] parcel_manager) 170 public void SaveParcels(ParcelData[] parcel_manager)
171 { 171 {
172 172
173 } 173 }
174 174
175 public void SaveParcel(ParcelData parcel) 175 public void SaveParcel(ParcelData parcel)
176 { 176 {
177 } 177 }
178 178
179 public void RemoveParcel(ParcelData parcel) 179 public void RemoveParcel(ParcelData parcel)
180 { 180 {
181 } 181 }
182 182
183 public void RemoveAllParcels() 183 public void RemoveAllParcels()
184 { 184 {
185 } 185 }
186 186
187 public void LoadParcels(ILocalStorageParcelReceiver recv) 187 public void LoadParcels(ILocalStorageParcelReceiver recv)
188 { 188 {
189 recv.NoParcelDataFromStorage(); 189 recv.NoParcelDataFromStorage();
190 } 190 }
191 191
192 public void ShutDown() 192 public void ShutDown()
193 { 193 {
194 db.Close(); 194 db.Close();
195 db = null; 195 db = null;
196 } 196 }
197 } 197 }
198} \ No newline at end of file 198} \ No newline at end of file
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
index 7c8bd07..3ce0967 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
@@ -1,65 +1,66 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Region.Environment.Scenes; 5using OpenSim.Region.Environment.Scenes;
6using OpenSim.Region.Environment; 6using OpenSim.Region.Environment;
7using OpenSim.Region.Interfaces; 7using OpenSim.Region.Interfaces;
8using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
9using libsecondlife; 9using libsecondlife;
10 10
11namespace OpenSim.DataStore.NullStorage 11namespace OpenSim.DataStore.NullStorage
12{ 12{
13 public class NullDataStore : IRegionDataStore 13 public class NullDataStore : IRegionDataStore
14 { 14 {
15 public void Initialise(string dbfile, string dbname) 15
16 { 16 public void Initialise(string dbfile, string dbname)
17 return; 17 {
18 } 18 return;
19 19 }
20 public void StoreObject(SceneObject obj) 20
21 { 21 public void StoreObject(SceneObject obj)
22 22 {
23 } 23
24 24 }
25 public void RemoveObject(LLUUID obj) 25
26 { 26 public void RemoveObject(LLUUID obj)
27 27 {
28 } 28
29 29 }
30 public List<SceneObject> LoadObjects() 30
31 { 31 public List<SceneObject> LoadObjects()
32 return new List<SceneObject>(); 32 {
33 } 33 return new List<SceneObject>();
34 34 }
35 public void StoreTerrain(double[,] ter) 35
36 { 36 public void StoreTerrain(double[,] ter)
37 37 {
38 } 38
39 39 }
40 public double[,] LoadTerrain() 40
41 { 41 public double[,] LoadTerrain()
42 return null; 42 {
43 } 43 return null;
44 44 }
45 public void RemoveParcel(uint id) 45
46 { 46 public void RemoveParcel(uint id)
47 47 {
48 } 48
49 49 }
50 public void StoreParcel(OpenSim.Region.Environment.Parcel parcel) 50
51 { 51 public void StoreParcel(OpenSim.Region.Environment.Parcel parcel)
52 52 {
53 } 53
54 54 }
55 public List<OpenSim.Region.Environment.Parcel> LoadParcels() 55
56 { 56 public List<OpenSim.Region.Environment.Parcel> LoadParcels()
57 return new List<OpenSim.Region.Environment.Parcel>(); 57 {
58 } 58 return new List<OpenSim.Region.Environment.Parcel>();
59 59 }
60 public void Shutdown() 60
61 { 61 public void Shutdown()
62 62 {
63 } 63
64 } 64 }
65} 65 }
66}
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs
index c0bd46d..fd86315 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs
@@ -1,35 +1,35 @@
1using System.Reflection; 1using System.Reflection;
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.DataStore.NullStorage")] 8[assembly: AssemblyTitle("OpenSim.DataStore.NullStorage")]
9[assembly: AssemblyDescription("")] 9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")] 10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")] 11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.DataStore.NullStorage")] 12[assembly: AssemblyProduct("OpenSim.DataStore.NullStorage")]
13[assembly: AssemblyCopyright("Copyright © 2007")] 13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
22// The following GUID is for the ID of the typelib if this project is exposed to COM 22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("b4a1656d-de22-4080-a970-fd8166acbf16")] 23[assembly: Guid("b4a1656d-de22-4080-a970-fd8166acbf16")]
24 24
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32// You can specify all the values or you can default the Revision and Build Numbers 32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below: 33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")] 34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")] 35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
index 9c721d1..c523cd6 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
@@ -1,60 +1,60 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// General Information about an assembly is controlled through the following 30// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information 31// set of attributes. Change these attribute values to modify the information
32// associated with an assembly. 32// associated with an assembly.
33[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")] 33[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
34[assembly: AssemblyDescription("")] 34[assembly: AssemblyDescription("")]
35[assembly: AssemblyConfiguration("")] 35[assembly: AssemblyConfiguration("")]
36[assembly: AssemblyCompany("")] 36[assembly: AssemblyCompany("")]
37[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")] 37[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
38[assembly: AssemblyCopyright("Copyright © 2007")] 38[assembly: AssemblyCopyright("Copyright © 2007")]
39[assembly: AssemblyTrademark("")] 39[assembly: AssemblyTrademark("")]
40[assembly: AssemblyCulture("")] 40[assembly: AssemblyCulture("")]
41 41
42// Setting ComVisible to false makes the types in this assembly not visible 42// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from 43// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type. 44// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)] 45[assembly: ComVisible(false)]
46 46
47// The following GUID is for the ID of the typelib if this project is exposed to COM 47// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")] 48[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
49 49
50// Version information for an assembly consists of the following four values: 50// Version information for an assembly consists of the following four values:
51// 51//
52// Major Version 52// Major Version
53// Minor Version 53// Minor Version
54// Build Number 54// Build Number
55// Revision 55// Revision
56// 56//
57// You can specify all the values or you can default the Revision and Build Numbers 57// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below: 58// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")] 59[assembly: AssemblyVersion("1.0.0.0")]
60[assembly: AssemblyFileVersion("1.0.0.0")] 60[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index f017e44..6f3afea 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -1,954 +1,954 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using System.IO; 32using System.IO;
33using libTerrain; 33using libTerrain;
34using OpenJPEGNet; 34using OpenJPEGNet;
35 35
36namespace OpenSim.Region.Terrain 36namespace OpenSim.Region.Terrain
37{ 37{
38 public class TerrainCommand 38 public class TerrainCommand
39 { 39 {
40 public virtual bool run(string[] cmdargs, ref string output) 40 public virtual bool run(string[] cmdargs, ref string output)
41 { 41 {
42 return false; 42 return false;
43 } 43 }
44 44
45 public string args; 45 public string args;
46 public string help; 46 public string help;
47 } 47 }
48 48
49 public class TerrainEngine 49 public class TerrainEngine
50 { 50 {
51 /// <summary> 51 /// <summary>
52 /// Plugin library for scripts 52 /// Plugin library for scripts
53 /// </summary> 53 /// </summary>
54 public FilterHost customFilters = new FilterHost(); 54 public FilterHost customFilters = new FilterHost();
55 55
56 /// <summary> 56 /// <summary>
57 /// A [normally] 256x256 heightmap 57 /// A [normally] 256x256 heightmap
58 /// </summary> 58 /// </summary>
59 public Channel heightmap; 59 public Channel heightmap;
60 60
61 /// <summary> 61 /// <summary>
62 /// A copy of heightmap at the last save point (for reverting) 62 /// A copy of heightmap at the last save point (for reverting)
63 /// </summary> 63 /// </summary>
64 public Channel revertmap; 64 public Channel revertmap;
65 65
66 /// <summary> 66 /// <summary>
67 /// Water heightmap (needs clientside mods to work) 67 /// Water heightmap (needs clientside mods to work)
68 /// </summary> 68 /// </summary>
69 public Channel watermap; 69 public Channel watermap;
70 70
71 /// <summary> 71 /// <summary>
72 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. 72 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine.
73 /// Counts the number of modifications since the last save. (0 = Untainted) 73 /// Counts the number of modifications since the last save. (0 = Untainted)
74 /// </summary> 74 /// </summary>
75 public int tainted; 75 public int tainted;
76 76
77 int w, h; 77 int w, h;
78 78
79 /// <summary> 79 /// <summary>
80 /// Generate a new TerrainEngine instance and creates a new heightmap 80 /// Generate a new TerrainEngine instance and creates a new heightmap
81 /// </summary> 81 /// </summary>
82 public TerrainEngine() 82 public TerrainEngine()
83 { 83 {
84 w = 256; 84 w = 256;
85 h = 256; 85 h = 256;
86 heightmap = new Channel(w, h); 86 heightmap = new Channel(w, h);
87 87
88 tainted++; 88 tainted++;
89 } 89 }
90 90
91 /// <summary> 91 /// <summary>
92 /// Converts the heightmap to a 65536 value 1D floating point array 92 /// Converts the heightmap to a 65536 value 1D floating point array
93 /// </summary> 93 /// </summary>
94 /// <returns>A float[65536] array containing the heightmap</returns> 94 /// <returns>A float[65536] array containing the heightmap</returns>
95 public float[] getHeights1D() 95 public float[] getHeights1D()
96 { 96 {
97 float[] heights = new float[w * h]; 97 float[] heights = new float[w * h];
98 int i; 98 int i;
99 99
100 for (i = 0; i < w * h; i++) 100 for (i = 0; i < w * h; i++)
101 { 101 {
102 heights[i] = (float)heightmap.map[i / w, i % w]; 102 heights[i] = (float)heightmap.map[i / w, i % w];
103 } 103 }
104 104
105 return heights; 105 return heights;
106 } 106 }
107 107
108 /// <summary> 108 /// <summary>
109 /// Converts the heightmap to a 256x256 value 2D floating point array. 109 /// Converts the heightmap to a 256x256 value 2D floating point array.
110 /// </summary> 110 /// </summary>
111 /// <returns>An array of 256,256 values containing the heightmap</returns> 111 /// <returns>An array of 256,256 values containing the heightmap</returns>
112 public float[,] getHeights2D() 112 public float[,] getHeights2D()
113 { 113 {
114 float[,] heights = new float[w, h]; 114 float[,] heights = new float[w, h];
115 int x, y; 115 int x, y;
116 for (x = 0; x < w; x++) 116 for (x = 0; x < w; x++)
117 { 117 {
118 for (y = 0; y < h; y++) 118 for (y = 0; y < h; y++)
119 { 119 {
120 heights[x, y] = (float)heightmap.map[x, y]; 120 heights[x, y] = (float)heightmap.map[x, y];
121 } 121 }
122 } 122 }
123 return heights; 123 return heights;
124 } 124 }
125 125
126 /// <summary> 126 /// <summary>
127 /// Converts the heightmap to a 256x256 value 2D floating point array. Double precision version. 127 /// Converts the heightmap to a 256x256 value 2D floating point array. Double precision version.
128 /// </summary> 128 /// </summary>
129 /// <returns>An array of 256,256 values containing the heightmap</returns> 129 /// <returns>An array of 256,256 values containing the heightmap</returns>
130 public double[,] getHeights2DD() 130 public double[,] getHeights2DD()
131 { 131 {
132 return heightmap.map; 132 return heightmap.map;
133 } 133 }
134 134
135 /// <summary> 135 /// <summary>
136 /// Imports a 1D floating point array into the 2D heightmap array 136 /// Imports a 1D floating point array into the 2D heightmap array
137 /// </summary> 137 /// </summary>
138 /// <param name="heights">The array to import (must have 65536 members)</param> 138 /// <param name="heights">The array to import (must have 65536 members)</param>
139 public void setHeights1D(float[] heights) 139 public void setHeights1D(float[] heights)
140 { 140 {
141 int i; 141 int i;
142 for (i = 0; i < w * h; i++) 142 for (i = 0; i < w * h; i++)
143 { 143 {
144 heightmap.map[i / w, i % w] = heights[i]; 144 heightmap.map[i / w, i % w] = heights[i];
145 } 145 }
146 146
147 tainted++; 147 tainted++;
148 } 148 }
149 149
150 /// <summary> 150 /// <summary>
151 /// Loads a 2D array of values into the heightmap 151 /// Loads a 2D array of values into the heightmap
152 /// </summary> 152 /// </summary>
153 /// <param name="heights">An array of 256,256 float values</param> 153 /// <param name="heights">An array of 256,256 float values</param>
154 public void setHeights2D(float[,] heights) 154 public void setHeights2D(float[,] heights)
155 { 155 {
156 int x, y; 156 int x, y;
157 for (x = 0; x < w; x++) 157 for (x = 0; x < w; x++)
158 { 158 {
159 for (y = 0; y < h; y++) 159 for (y = 0; y < h; y++)
160 { 160 {
161 heightmap.set(x, y, (double)heights[x, y]); 161 heightmap.set(x, y, (double)heights[x, y]);
162 } 162 }
163 } 163 }
164 tainted++; 164 tainted++;
165 } 165 }
166 166
167 /// <summary> 167 /// <summary>
168 /// Loads a 2D array of values into the heightmap (Double Precision Version) 168 /// Loads a 2D array of values into the heightmap (Double Precision Version)
169 /// </summary> 169 /// </summary>
170 /// <param name="heights">An array of 256,256 float values</param> 170 /// <param name="heights">An array of 256,256 float values</param>
171 public void setHeights2D(double[,] heights) 171 public void setHeights2D(double[,] heights)
172 { 172 {
173 int x, y; 173 int x, y;
174 for (x = 0; x < w; x++) 174 for (x = 0; x < w; x++)
175 { 175 {
176 for (y = 0; y < h; y++) 176 for (y = 0; y < h; y++)
177 { 177 {
178 heightmap.set(x, y, heights[x, y]); 178 heightmap.set(x, y, heights[x, y]);
179 } 179 }
180 } 180 }
181 tainted++; 181 tainted++;
182 } 182 }
183 183
184 /// <summary> 184 /// <summary>
185 /// Swaps the two heightmap buffers (the 'revert map' and the heightmap) 185 /// Swaps the two heightmap buffers (the 'revert map' and the heightmap)
186 /// </summary> 186 /// </summary>
187 public void swapRevertMaps() 187 public void swapRevertMaps()
188 { 188 {
189 Channel backup = heightmap.copy(); 189 Channel backup = heightmap.copy();
190 heightmap = revertmap; 190 heightmap = revertmap;
191 revertmap = backup; 191 revertmap = backup;
192 } 192 }
193 193
194 /// <summary> 194 /// <summary>
195 /// Saves the current heightmap into the revertmap 195 /// Saves the current heightmap into the revertmap
196 /// </summary> 196 /// </summary>
197 public void saveRevertMap() 197 public void saveRevertMap()
198 { 198 {
199 revertmap = heightmap.copy(); 199 revertmap = heightmap.copy();
200 } 200 }
201 201
202 /// <summary> 202 /// <summary>
203 /// Processes a terrain-specific command 203 /// Processes a terrain-specific command
204 /// </summary> 204 /// </summary>
205 /// <param name="args">Commandline arguments (space seperated)</param> 205 /// <param name="args">Commandline arguments (space seperated)</param>
206 /// <param name="resultText">Reference that returns error or help text if returning false</param> 206 /// <param name="resultText">Reference that returns error or help text if returning false</param>
207 /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns> 207 /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns>
208 public bool RunTerrainCmd(string[] args, ref string resultText, string simName) 208 public bool RunTerrainCmd(string[] args, ref string resultText, string simName)
209 { 209 {
210 string command = args[0]; 210 string command = args[0];
211 211
212 try 212 try
213 { 213 {
214 214
215 switch (command) 215 switch (command)
216 { 216 {
217 case "help": 217 case "help":
218 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; 218 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
219 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block"; 219 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block";
220 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; 220 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
221 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; 221 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
222 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n"; 222 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
223 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n"; 223 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
224 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; 224 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
225 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n"; 225 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
226 resultText += "terrain erode thermal <talus> <rounds> <carry>\n"; 226 resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
227 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n"; 227 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
228 resultText += "terrain revert - reverts the terrain to the stored original\n"; 228 resultText += "terrain revert - reverts the terrain to the stored original\n";
229 resultText += "terrain bake - saves the current terrain into the revert map\n"; 229 resultText += "terrain bake - saves the current terrain into the revert map\n";
230 resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n"; 230 resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n";
231 resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n"; 231 resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n";
232 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters) 232 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters)
233 { 233 {
234 resultText += filter.Value.Help(); 234 resultText += filter.Value.Help();
235 } 235 }
236 236
237 return false; 237 return false;
238 238
239 case "revert": 239 case "revert":
240 swapRevertMaps(); 240 swapRevertMaps();
241 saveRevertMap(); 241 saveRevertMap();
242 break; 242 break;
243 243
244 case "bake": 244 case "bake":
245 saveRevertMap(); 245 saveRevertMap();
246 break; 246 break;
247 247
248 case "seed": 248 case "seed":
249 setSeed(Convert.ToInt32(args[1])); 249 setSeed(Convert.ToInt32(args[1]));
250 break; 250 break;
251 251
252 case "erode": 252 case "erode":
253 return consoleErosion(args, ref resultText); 253 return consoleErosion(args, ref resultText);
254 254
255 case "voronoi": 255 case "voronoi":
256 double[] c = new double[2]; 256 double[] c = new double[2];
257 c[0] = -1; 257 c[0] = -1;
258 c[1] = 1; 258 c[1] = 1;
259 heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c); 259 heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c);
260 break; 260 break;
261 261
262 case "hills": 262 case "hills":
263 return consoleHills(args, ref resultText); 263 return consoleHills(args, ref resultText);
264 264
265 case "regenerate": 265 case "regenerate":
266 hills(); 266 hills();
267 break; 267 break;
268 268
269 case "rescale": 269 case "rescale":
270 setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); 270 setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
271 break; 271 break;
272 272
273 case "multiply": 273 case "multiply":
274 heightmap *= Convert.ToDouble(args[1]); 274 heightmap *= Convert.ToDouble(args[1]);
275 break; 275 break;
276 276
277 case "load": 277 case "load":
278 args[2].Replace("%name%", simName); 278 args[2].Replace("%name%", simName);
279 switch (args[1].ToLower()) 279 switch (args[1].ToLower())
280 { 280 {
281 case "f32": 281 case "f32":
282 loadFromFileF32(args[2]); 282 loadFromFileF32(args[2]);
283 break; 283 break;
284 284
285 case "f64": 285 case "f64":
286 loadFromFileF64(args[2]); 286 loadFromFileF64(args[2]);
287 break; 287 break;
288 288
289 case "raw": 289 case "raw":
290 loadFromFileSLRAW(args[2]); 290 loadFromFileSLRAW(args[2]);
291 break; 291 break;
292 292
293 case "img": 293 case "img":
294 heightmap.loadImage(args[2]); 294 heightmap.loadImage(args[2]);
295 return false; 295 return false;
296 296
297 default: 297 default:
298 resultText = "Unknown image or data format"; 298 resultText = "Unknown image or data format";
299 return false; 299 return false;
300 } 300 }
301 break; 301 break;
302 302
303 case "save": 303 case "save":
304 args[2].Replace("%name%", simName); 304 args[2].Replace("%name%", simName);
305 switch (args[1].ToLower()) 305 switch (args[1].ToLower())
306 { 306 {
307 case "f32": 307 case "f32":
308 writeToFileF32(args[2]); 308 writeToFileF32(args[2]);
309 break; 309 break;
310 310
311 case "f64": 311 case "f64":
312 writeToFileF64(args[2]); 312 writeToFileF64(args[2]);
313 break; 313 break;
314 314
315 case "grdmap": 315 case "grdmap":
316 exportImage(args[2], args[3]); 316 exportImage(args[2], args[3]);
317 break; 317 break;
318 318
319 case "png": 319 case "png":
320 heightmap.saveImage(args[2]); 320 heightmap.saveImage(args[2]);
321 break; 321 break;
322 322
323 case "raw": 323 case "raw":
324 writeToFileRAW(args[2]); 324 writeToFileRAW(args[2]);
325 break; 325 break;
326 326
327 case "hiraw": 327 case "hiraw":
328 writeToFileHiRAW(args[2]); 328 writeToFileHiRAW(args[2]);
329 break; 329 break;
330 330
331 default: 331 default:
332 resultText = "Unknown image or data format"; 332 resultText = "Unknown image or data format";
333 return false; 333 return false;
334 } 334 }
335 break; 335 break;
336 336
337 case "csfilter": 337 case "csfilter":
338 customFilters.LoadFilterCSharp(args[1]); 338 customFilters.LoadFilterCSharp(args[1]);
339 break; 339 break;
340 case "jsfilter": 340 case "jsfilter":
341 customFilters.LoadFilterJScript(args[1]); 341 customFilters.LoadFilterJScript(args[1]);
342 break; 342 break;
343 343
344 default: 344 default:
345 // Run any custom registered filters 345 // Run any custom registered filters
346 if (customFilters.filters.ContainsKey(command)) 346 if (customFilters.filters.ContainsKey(command))
347 { 347 {
348 customFilters.filters[command].Filter(heightmap, args); 348 customFilters.filters[command].Filter(heightmap, args);
349 break; 349 break;
350 } 350 }
351 else 351 else
352 { 352 {
353 resultText = "Unknown terrain command"; 353 resultText = "Unknown terrain command";
354 return false; 354 return false;
355 } 355 }
356 } 356 }
357 return true; 357 return true;
358 } 358 }
359 catch (Exception e) 359 catch (Exception e)
360 { 360 {
361 resultText = "Error running terrain command: " + e.ToString(); 361 resultText = "Error running terrain command: " + e.ToString();
362 return false; 362 return false;
363 } 363 }
364 } 364 }
365 365
366 private bool consoleErosion(string[] args, ref string resultText) 366 private bool consoleErosion(string[] args, ref string resultText)
367 { 367 {
368 switch (args[1].ToLower()) 368 switch (args[1].ToLower())
369 { 369 {
370 case "aerobic": 370 case "aerobic":
371 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest 371 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
372 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7])); 372 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]));
373 break; 373 break;
374 case "thermal": 374 case "thermal":
375 heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); 375 heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4]));
376 break; 376 break;
377 default: 377 default:
378 resultText = "Unknown erosion type"; 378 resultText = "Unknown erosion type";
379 return false; 379 return false;
380 } 380 }
381 return true; 381 return true;
382 } 382 }
383 383
384 private bool consoleHills(string[] args, ref string resultText) 384 private bool consoleHills(string[] args, ref string resultText)
385 { 385 {
386 int count; 386 int count;
387 double sizeMin; 387 double sizeMin;
388 double sizeRange; 388 double sizeRange;
389 bool island; 389 bool island;
390 bool additive; 390 bool additive;
391 bool noisy; 391 bool noisy;
392 392
393 if (args.GetLength(0) > 2) 393 if (args.GetLength(0) > 2)
394 { 394 {
395 count = Convert.ToInt32(args[2]); 395 count = Convert.ToInt32(args[2]);
396 sizeMin = Convert.ToDouble(args[3]); 396 sizeMin = Convert.ToDouble(args[3]);
397 sizeRange = Convert.ToDouble(args[4]); 397 sizeRange = Convert.ToDouble(args[4]);
398 island = Convert.ToBoolean(args[5]); 398 island = Convert.ToBoolean(args[5]);
399 additive = Convert.ToBoolean(args[6]); 399 additive = Convert.ToBoolean(args[6]);
400 noisy = Convert.ToBoolean(args[7]); 400 noisy = Convert.ToBoolean(args[7]);
401 } 401 }
402 else 402 else
403 { 403 {
404 count = 200; 404 count = 200;
405 sizeMin = 20; 405 sizeMin = 20;
406 sizeRange = 40; 406 sizeRange = 40;
407 island = true; 407 island = true;
408 additive = true; 408 additive = true;
409 noisy = false; 409 noisy = false;
410 } 410 }
411 411
412 switch (args[1].ToLower()) 412 switch (args[1].ToLower())
413 { 413 {
414 case "blocks": 414 case "blocks":
415 heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy); 415 heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy);
416 break; 416 break;
417 case "cones": 417 case "cones":
418 heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy); 418 heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy);
419 break; 419 break;
420 case "spheres": 420 case "spheres":
421 heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy); 421 heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy);
422 break; 422 break;
423 case "squared": 423 case "squared":
424 heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy); 424 heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy);
425 break; 425 break;
426 default: 426 default:
427 resultText = "Unknown hills type"; 427 resultText = "Unknown hills type";
428 return false; 428 return false;
429 } 429 }
430 return true; 430 return true;
431 } 431 }
432 432
433 /// <summary> 433 /// <summary>
434 /// Renormalises the array between min and max 434 /// Renormalises the array between min and max
435 /// </summary> 435 /// </summary>
436 /// <param name="min">Minimum value of the new array</param> 436 /// <param name="min">Minimum value of the new array</param>
437 /// <param name="max">Maximum value of the new array</param> 437 /// <param name="max">Maximum value of the new array</param>
438 public void setRange(float min, float max) 438 public void setRange(float min, float max)
439 { 439 {
440 heightmap.normalise((double)min, (double)max); 440 heightmap.normalise((double)min, (double)max);
441 tainted++; 441 tainted++;
442 } 442 }
443 443
444 /// <summary> 444 /// <summary>
445 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. 445 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
446 /// </summary> 446 /// </summary>
447 /// <remarks>TODO: Move this to libTerrain itself</remarks> 447 /// <remarks>TODO: Move this to libTerrain itself</remarks>
448 /// <param name="filename">The filename of the double array to import</param> 448 /// <param name="filename">The filename of the double array to import</param>
449 public void loadFromFileF64(string filename) 449 public void loadFromFileF64(string filename)
450 { 450 {
451 FileInfo file = new FileInfo(filename); 451 FileInfo file = new FileInfo(filename);
452 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 452 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
453 BinaryReader bs = new BinaryReader(s); 453 BinaryReader bs = new BinaryReader(s);
454 int x, y; 454 int x, y;
455 for (x = 0; x < w; x++) 455 for (x = 0; x < w; x++)
456 { 456 {
457 for (y = 0; y < h; y++) 457 for (y = 0; y < h; y++)
458 { 458 {
459 heightmap.map[x, y] = bs.ReadDouble(); 459 heightmap.map[x, y] = bs.ReadDouble();
460 } 460 }
461 } 461 }
462 462
463 bs.Close(); 463 bs.Close();
464 s.Close(); 464 s.Close();
465 465
466 tainted++; 466 tainted++;
467 } 467 }
468 468
469 /// <summary> 469 /// <summary>
470 /// Loads a file consisting of 256x256 floats and imports it as an array into the map. 470 /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
471 /// </summary> 471 /// </summary>
472 /// <remarks>TODO: Move this to libTerrain itself</remarks> 472 /// <remarks>TODO: Move this to libTerrain itself</remarks>
473 /// <param name="filename">The filename of the float array to import</param> 473 /// <param name="filename">The filename of the float array to import</param>
474 public void loadFromFileF32(string filename) 474 public void loadFromFileF32(string filename)
475 { 475 {
476 FileInfo file = new FileInfo(filename); 476 FileInfo file = new FileInfo(filename);
477 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 477 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
478 BinaryReader bs = new BinaryReader(s); 478 BinaryReader bs = new BinaryReader(s);
479 int x, y; 479 int x, y;
480 for (x = 0; x < w; x++) 480 for (x = 0; x < w; x++)
481 { 481 {
482 for (y = 0; y < h; y++) 482 for (y = 0; y < h; y++)
483 { 483 {
484 heightmap.map[x, y] = (double)bs.ReadSingle(); 484 heightmap.map[x, y] = (double)bs.ReadSingle();
485 } 485 }
486 } 486 }
487 487
488 bs.Close(); 488 bs.Close();
489 s.Close(); 489 s.Close();
490 490
491 tainted++; 491 tainted++;
492 } 492 }
493 493
494 /// <summary> 494 /// <summary>
495 /// Loads a file formatted in the SL .RAW Format used on the main grid 495 /// Loads a file formatted in the SL .RAW Format used on the main grid
496 /// </summary> 496 /// </summary>
497 /// <remarks>This file format stinks and is best avoided.</remarks> 497 /// <remarks>This file format stinks and is best avoided.</remarks>
498 /// <param name="filename">A path to the .RAW format</param> 498 /// <param name="filename">A path to the .RAW format</param>
499 public void loadFromFileSLRAW(string filename) 499 public void loadFromFileSLRAW(string filename)
500 { 500 {
501 FileInfo file = new FileInfo(filename); 501 FileInfo file = new FileInfo(filename);
502 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 502 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
503 BinaryReader bs = new BinaryReader(s); 503 BinaryReader bs = new BinaryReader(s);
504 int x, y; 504 int x, y;
505 for (x = 0; x < w; x++) 505 for (x = 0; x < w; x++)
506 { 506 {
507 for (y = 0; y < h; y++) 507 for (y = 0; y < h; y++)
508 { 508 {
509 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0); 509 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
510 bs.ReadBytes(11); // Advance the stream to next bytes. 510 bs.ReadBytes(11); // Advance the stream to next bytes.
511 } 511 }
512 } 512 }
513 513
514 bs.Close(); 514 bs.Close();
515 s.Close(); 515 s.Close();
516 516
517 tainted++; 517 tainted++;
518 } 518 }
519 519
520 /// <summary> 520 /// <summary>
521 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. 521 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
522 /// </summary> 522 /// </summary>
523 /// <param name="filename">The desired output filename</param> 523 /// <param name="filename">The desired output filename</param>
524 public void writeToFileF64(string filename) 524 public void writeToFileF64(string filename)
525 { 525 {
526 FileInfo file = new FileInfo(filename); 526 FileInfo file = new FileInfo(filename);
527 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 527 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
528 BinaryWriter bs = new BinaryWriter(s); 528 BinaryWriter bs = new BinaryWriter(s);
529 529
530 int x, y; 530 int x, y;
531 for (x = 0; x < w; x++) 531 for (x = 0; x < w; x++)
532 { 532 {
533 for (y = 0; y < h; y++) 533 for (y = 0; y < h; y++)
534 { 534 {
535 bs.Write(heightmap.get(x, y)); 535 bs.Write(heightmap.get(x, y));
536 } 536 }
537 } 537 }
538 538
539 bs.Close(); 539 bs.Close();
540 s.Close(); 540 s.Close();
541 } 541 }
542 542
543 /// <summary> 543 /// <summary>
544 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array 544 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array
545 /// </summary> 545 /// </summary>
546 /// <param name="filename">The desired output filename</param> 546 /// <param name="filename">The desired output filename</param>
547 public void writeToFileF32(string filename) 547 public void writeToFileF32(string filename)
548 { 548 {
549 FileInfo file = new FileInfo(filename); 549 FileInfo file = new FileInfo(filename);
550 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 550 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
551 BinaryWriter bs = new BinaryWriter(s); 551 BinaryWriter bs = new BinaryWriter(s);
552 552
553 int x, y; 553 int x, y;
554 for (x = 0; x < w; x++) 554 for (x = 0; x < w; x++)
555 { 555 {
556 for (y = 0; y < h; y++) 556 for (y = 0; y < h; y++)
557 { 557 {
558 bs.Write((float)heightmap.get(x, y)); 558 bs.Write((float)heightmap.get(x, y));
559 } 559 }
560 } 560 }
561 561
562 bs.Close(); 562 bs.Close();
563 s.Close(); 563 s.Close();
564 } 564 }
565 565
566 /// <summary> 566 /// <summary>
567 /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either. 567 /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either.
568 /// (is also editable in an image application) 568 /// (is also editable in an image application)
569 /// </summary> 569 /// </summary>
570 /// <param name="filename">Filename to write to</param> 570 /// <param name="filename">Filename to write to</param>
571 public void writeToFileRAW(string filename) 571 public void writeToFileRAW(string filename)
572 { 572 {
573 FileInfo file = new FileInfo(filename); 573 FileInfo file = new FileInfo(filename);
574 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 574 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
575 BinaryWriter bs = new BinaryWriter(s); 575 BinaryWriter bs = new BinaryWriter(s);
576 576
577 int x, y; 577 int x, y;
578 578
579 // Used for the 'green' channel. 579 // Used for the 'green' channel.
580 byte avgMultiplier = (byte)heightmap.avg(); 580 byte avgMultiplier = (byte)heightmap.avg();
581 byte backupMultiplier = (byte)revertmap.avg(); 581 byte backupMultiplier = (byte)revertmap.avg();
582 582
583 // Limit the multiplier so it can represent points >64m. 583 // Limit the multiplier so it can represent points >64m.
584 if (avgMultiplier > 196) 584 if (avgMultiplier > 196)
585 avgMultiplier = 196; 585 avgMultiplier = 196;
586 if(backupMultiplier > 196) 586 if(backupMultiplier > 196)
587 backupMultiplier = 196; 587 backupMultiplier = 196;
588 // Make sure it's at least one to prevent a div by zero 588 // Make sure it's at least one to prevent a div by zero
589 if (avgMultiplier < 1) 589 if (avgMultiplier < 1)
590 avgMultiplier = 1; 590 avgMultiplier = 1;
591 if(backupMultiplier < 1) 591 if(backupMultiplier < 1)
592 backupMultiplier = 1; 592 backupMultiplier = 1;
593 593
594 for (x = 0; x < w; x++) 594 for (x = 0; x < w; x++)
595 { 595 {
596 for (y = 0; y < h; y++) 596 for (y = 0; y < h; y++)
597 { 597 {
598 byte red = (byte)(heightmap.get(x, y) / ((double)avgMultiplier / 128.0)); 598 byte red = (byte)(heightmap.get(x, y) / ((double)avgMultiplier / 128.0));
599 byte green = avgMultiplier; 599 byte green = avgMultiplier;
600 byte blue = (byte)watermap.get(x, y); 600 byte blue = (byte)watermap.get(x, y);
601 byte alpha1 = 0; // Land Parcels 601 byte alpha1 = 0; // Land Parcels
602 byte alpha2 = 0; // For Sale Land 602 byte alpha2 = 0; // For Sale Land
603 byte alpha3 = 0; // Public Edit Object 603 byte alpha3 = 0; // Public Edit Object
604 byte alpha4 = 0; // Public Edit Land 604 byte alpha4 = 0; // Public Edit Land
605 byte alpha5 = 255; // Safe Land 605 byte alpha5 = 255; // Safe Land
606 byte alpha6 = 255; // Flying Allowed 606 byte alpha6 = 255; // Flying Allowed
607 byte alpha7 = 255; // Create Landmark 607 byte alpha7 = 255; // Create Landmark
608 byte alpha8 = 255; // Outside Scripts 608 byte alpha8 = 255; // Outside Scripts
609 byte alpha9 = (byte)(revertmap.get(x, y) / ((double)backupMultiplier / 128.0)); 609 byte alpha9 = (byte)(revertmap.get(x, y) / ((double)backupMultiplier / 128.0));
610 byte alpha10 = backupMultiplier; 610 byte alpha10 = backupMultiplier;
611 611
612 bs.Write(red); 612 bs.Write(red);
613 bs.Write(green); 613 bs.Write(green);
614 bs.Write(blue); 614 bs.Write(blue);
615 bs.Write(alpha1); 615 bs.Write(alpha1);
616 bs.Write(alpha2); 616 bs.Write(alpha2);
617 bs.Write(alpha3); 617 bs.Write(alpha3);
618 bs.Write(alpha4); 618 bs.Write(alpha4);
619 bs.Write(alpha5); 619 bs.Write(alpha5);
620 bs.Write(alpha6); 620 bs.Write(alpha6);
621 bs.Write(alpha7); 621 bs.Write(alpha7);
622 bs.Write(alpha8); 622 bs.Write(alpha8);
623 bs.Write(alpha9); 623 bs.Write(alpha9);
624 bs.Write(alpha10); 624 bs.Write(alpha10);
625 } 625 }
626 } 626 }
627 bs.Close(); 627 bs.Close();
628 s.Close(); 628 s.Close();
629 } 629 }
630 630
631 /// <summary> 631 /// <summary>
632 /// Outputs to a LL compatible RAW in the most efficient manner possible 632 /// Outputs to a LL compatible RAW in the most efficient manner possible
633 /// </summary> 633 /// </summary>
634 /// <remarks>Does not calculate the revert map</remarks> 634 /// <remarks>Does not calculate the revert map</remarks>
635 /// <param name="filename">The filename to output to</param> 635 /// <param name="filename">The filename to output to</param>
636 public void writeToFileHiRAW(string filename) 636 public void writeToFileHiRAW(string filename)
637 { 637 {
638 FileInfo file = new FileInfo(filename); 638 FileInfo file = new FileInfo(filename);
639 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 639 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
640 BinaryWriter bs = new BinaryWriter(s); 640 BinaryWriter bs = new BinaryWriter(s);
641 641
642 // Generate a smegging big lookup table to speed the operation up (it needs it) 642 // Generate a smegging big lookup table to speed the operation up (it needs it)
643 double[] lookupTable = new double[65536]; 643 double[] lookupTable = new double[65536];
644 int i, j, x, y; 644 int i, j, x, y;
645 for (i = 0; i < 256; i++) 645 for (i = 0; i < 256; i++)
646 { 646 {
647 for (j = 0; j < 256; j++) 647 for (j = 0; j < 256; j++)
648 { 648 {
649 lookupTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); 649 lookupTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
650 } 650 }
651 } 651 }
652 652
653 // Output the calculated raw 653 // Output the calculated raw
654 for (x = 0; x < w; x++) 654 for (x = 0; x < w; x++)
655 { 655 {
656 for (y = 0; y < h; y++) 656 for (y = 0; y < h; y++)
657 { 657 {
658 double t = heightmap.get(x, y); 658 double t = heightmap.get(x, y);
659 double min = double.MaxValue; 659 double min = double.MaxValue;
660 int index = 0; 660 int index = 0;
661 661
662 for (i = 0; i < 65536; i++) 662 for (i = 0; i < 65536; i++)
663 { 663 {
664 if (Math.Abs(t - lookupTable[i]) < min) 664 if (Math.Abs(t - lookupTable[i]) < min)
665 { 665 {
666 min = Math.Abs(t - lookupTable[i]); 666 min = Math.Abs(t - lookupTable[i]);
667 index = i; 667 index = i;
668 } 668 }
669 } 669 }
670 670
671 byte red = (byte)(index & 0xFF); 671 byte red = (byte)(index & 0xFF);
672 byte green = (byte)((index >> 8) & 0xFF); 672 byte green = (byte)((index >> 8) & 0xFF);
673 byte blue = (byte)watermap.get(x, y); 673 byte blue = (byte)watermap.get(x, y);
674 byte alpha1 = 0; // Land Parcels 674 byte alpha1 = 0; // Land Parcels
675 byte alpha2 = 0; // For Sale Land 675 byte alpha2 = 0; // For Sale Land
676 byte alpha3 = 0; // Public Edit Object 676 byte alpha3 = 0; // Public Edit Object
677 byte alpha4 = 0; // Public Edit Land 677 byte alpha4 = 0; // Public Edit Land
678 byte alpha5 = 255; // Safe Land 678 byte alpha5 = 255; // Safe Land
679 byte alpha6 = 255; // Flying Allowed 679 byte alpha6 = 255; // Flying Allowed
680 byte alpha7 = 255; // Create Landmark 680 byte alpha7 = 255; // Create Landmark
681 byte alpha8 = 255; // Outside Scripts 681 byte alpha8 = 255; // Outside Scripts
682 byte alpha9 = red; 682 byte alpha9 = red;
683 byte alpha10 = green; 683 byte alpha10 = green;
684 684
685 bs.Write(red); 685 bs.Write(red);
686 bs.Write(green); 686 bs.Write(green);
687 bs.Write(blue); 687 bs.Write(blue);
688 bs.Write(alpha1); 688 bs.Write(alpha1);
689 bs.Write(alpha2); 689 bs.Write(alpha2);
690 bs.Write(alpha3); 690 bs.Write(alpha3);
691 bs.Write(alpha4); 691 bs.Write(alpha4);
692 bs.Write(alpha5); 692 bs.Write(alpha5);
693 bs.Write(alpha6); 693 bs.Write(alpha6);
694 bs.Write(alpha7); 694 bs.Write(alpha7);
695 bs.Write(alpha8); 695 bs.Write(alpha8);
696 bs.Write(alpha9); 696 bs.Write(alpha9);
697 bs.Write(alpha10); 697 bs.Write(alpha10);
698 } 698 }
699 } 699 }
700 700
701 bs.Close(); 701 bs.Close();
702 s.Close(); 702 s.Close();
703 } 703 }
704 704
705 /// <summary> 705 /// <summary>
706 /// Sets the random seed to be used by procedural functions which involve random numbers. 706 /// Sets the random seed to be used by procedural functions which involve random numbers.
707 /// </summary> 707 /// </summary>
708 /// <param name="val">The desired seed</param> 708 /// <param name="val">The desired seed</param>
709 public void setSeed(int val) 709 public void setSeed(int val)
710 { 710 {
711 heightmap.seed = val; 711 heightmap.seed = val;
712 } 712 }
713 713
714 /// <summary> 714 /// <summary>
715 /// Raises land in a sphere around the specified coordinates 715 /// Raises land in a sphere around the specified coordinates
716 /// </summary> 716 /// </summary>
717 /// <param name="rx">Center of the sphere on the X axis</param> 717 /// <param name="rx">Center of the sphere on the X axis</param>
718 /// <param name="ry">Center of the sphere on the Y axis</param> 718 /// <param name="ry">Center of the sphere on the Y axis</param>
719 /// <param name="size">The radius of the sphere</param> 719 /// <param name="size">The radius of the sphere</param>
720 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> 720 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
721 public void raise(double rx, double ry, double size, double amount) 721 public void raise(double rx, double ry, double size, double amount)
722 { 722 {
723 lock (heightmap) 723 lock (heightmap)
724 { 724 {
725 heightmap.raise(rx, ry, size, amount); 725 heightmap.raise(rx, ry, size, amount);
726 } 726 }
727 727
728 tainted++; 728 tainted++;
729 } 729 }
730 730
731 /// <summary> 731 /// <summary>
732 /// Lowers the land in a sphere around the specified coordinates 732 /// Lowers the land in a sphere around the specified coordinates
733 /// </summary> 733 /// </summary>
734 /// <param name="rx">The center of the sphere at the X axis</param> 734 /// <param name="rx">The center of the sphere at the X axis</param>
735 /// <param name="ry">The center of the sphere at the Y axis</param> 735 /// <param name="ry">The center of the sphere at the Y axis</param>
736 /// <param name="size">The radius of the sphere in meters</param> 736 /// <param name="size">The radius of the sphere in meters</param>
737 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> 737 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
738 public void lower(double rx, double ry, double size, double amount) 738 public void lower(double rx, double ry, double size, double amount)
739 { 739 {
740 lock (heightmap) 740 lock (heightmap)
741 { 741 {
742 heightmap.lower(rx, ry, size, amount); 742 heightmap.lower(rx, ry, size, amount);
743 } 743 }
744 744
745 tainted++; 745 tainted++;
746 } 746 }
747 747
748 /// <summary> 748 /// <summary>
749 /// Flattens the land under the brush of specified coordinates (spherical mask) 749 /// Flattens the land under the brush of specified coordinates (spherical mask)
750 /// </summary> 750 /// </summary>
751 /// <param name="rx">Center of sphere</param> 751 /// <param name="rx">Center of sphere</param>
752 /// <param name="ry">Center of sphere</param> 752 /// <param name="ry">Center of sphere</param>
753 /// <param name="size">Radius of the sphere</param> 753 /// <param name="size">Radius of the sphere</param>
754 /// <param name="amount">Thickness of the mask (0..2 recommended)</param> 754 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
755 public void flatten(double rx, double ry, double size, double amount) 755 public void flatten(double rx, double ry, double size, double amount)
756 { 756 {
757 lock (heightmap) 757 lock (heightmap)
758 { 758 {
759 heightmap.flatten(rx, ry, size, amount); 759 heightmap.flatten(rx, ry, size, amount);
760 } 760 }
761 761
762 tainted++; 762 tainted++;
763 } 763 }
764 764
765 /// <summary> 765 /// <summary>
766 /// Creates noise within the specified bounds 766 /// Creates noise within the specified bounds
767 /// </summary> 767 /// </summary>
768 /// <param name="rx">Center of the bounding sphere</param> 768 /// <param name="rx">Center of the bounding sphere</param>
769 /// <param name="ry">Center of the bounding sphere</param> 769 /// <param name="ry">Center of the bounding sphere</param>
770 /// <param name="size">The radius of the sphere</param> 770 /// <param name="size">The radius of the sphere</param>
771 /// <param name="amount">Strength of the mask (0..2) recommended</param> 771 /// <param name="amount">Strength of the mask (0..2) recommended</param>
772 public void noise(double rx, double ry, double size, double amount) 772 public void noise(double rx, double ry, double size, double amount)
773 { 773 {
774 lock (heightmap) 774 lock (heightmap)
775 { 775 {
776 Channel smoothed = new Channel(); 776 Channel smoothed = new Channel();
777 smoothed.noise(); 777 smoothed.noise();
778 778
779 Channel mask = new Channel(); 779 Channel mask = new Channel();
780 mask.raise(rx, ry, size, amount); 780 mask.raise(rx, ry, size, amount);
781 781
782 heightmap.blend(smoothed, mask); 782 heightmap.blend(smoothed, mask);
783 } 783 }
784 784
785 tainted++; 785 tainted++;
786 } 786 }
787 787
788 /// <summary> 788 /// <summary>
789 /// Reverts land within the specified bounds 789 /// Reverts land within the specified bounds
790 /// </summary> 790 /// </summary>
791 /// <param name="rx">Center of the bounding sphere</param> 791 /// <param name="rx">Center of the bounding sphere</param>
792 /// <param name="ry">Center of the bounding sphere</param> 792 /// <param name="ry">Center of the bounding sphere</param>
793 /// <param name="size">The radius of the sphere</param> 793 /// <param name="size">The radius of the sphere</param>
794 /// <param name="amount">Strength of the mask (0..2) recommended</param> 794 /// <param name="amount">Strength of the mask (0..2) recommended</param>
795 public void revert(double rx, double ry, double size, double amount) 795 public void revert(double rx, double ry, double size, double amount)
796 { 796 {
797 lock (heightmap) 797 lock (heightmap)
798 { 798 {
799 Channel mask = new Channel(); 799 Channel mask = new Channel();
800 mask.raise(rx, ry, size, amount); 800 mask.raise(rx, ry, size, amount);
801 801
802 heightmap.blend(revertmap, mask); 802 heightmap.blend(revertmap, mask);
803 } 803 }
804 804
805 tainted++; 805 tainted++;
806 } 806 }
807 807
808 /// <summary> 808 /// <summary>
809 /// Smooths land under the brush of specified coordinates (spherical mask) 809 /// Smooths land under the brush of specified coordinates (spherical mask)
810 /// </summary> 810 /// </summary>
811 /// <param name="rx">Center of the sphere</param> 811 /// <param name="rx">Center of the sphere</param>
812 /// <param name="ry">Center of the sphere</param> 812 /// <param name="ry">Center of the sphere</param>
813 /// <param name="size">Radius of the sphere</param> 813 /// <param name="size">Radius of the sphere</param>
814 /// <param name="amount">Thickness of the mask (0..2 recommended)</param> 814 /// <param name="amount">Thickness of the mask (0..2 recommended)</param>
815 public void smooth(double rx, double ry, double size, double amount) 815 public void smooth(double rx, double ry, double size, double amount)
816 { 816 {
817 lock (heightmap) 817 lock (heightmap)
818 { 818 {
819 Channel smoothed = heightmap.copy(); 819 Channel smoothed = heightmap.copy();
820 smoothed.smooth(amount); 820 smoothed.smooth(amount);
821 821
822 Channel mask = new Channel(); 822 Channel mask = new Channel();
823 mask.raise(rx,ry,size,amount); 823 mask.raise(rx,ry,size,amount);
824 824
825 heightmap.blend(smoothed, mask); 825 heightmap.blend(smoothed, mask);
826 } 826 }
827 827
828 tainted++; 828 tainted++;
829 } 829 }
830 830
831 /// <summary> 831 /// <summary>
832 /// Generates a simple set of hills in the shape of an island 832 /// Generates a simple set of hills in the shape of an island
833 /// </summary> 833 /// </summary>
834 public void hills() 834 public void hills()
835 { 835 {
836 lock (heightmap) 836 lock (heightmap)
837 { 837 {
838 heightmap.hillsSpheres(200, 20, 40, true, true, false); 838 heightmap.hillsSpheres(200, 20, 40, true, true, false);
839 heightmap.normalise(); 839 heightmap.normalise();
840 heightmap *= 60.0; // Raise to 60m 840 heightmap *= 60.0; // Raise to 60m
841 } 841 }
842 842
843 tainted++; 843 tainted++;
844 } 844 }
845 845
846 /// <summary> 846 /// <summary>
847 /// Wrapper to heightmap.get() 847 /// Wrapper to heightmap.get()
848 /// </summary> 848 /// </summary>
849 /// <param name="x">X coord</param> 849 /// <param name="x">X coord</param>
850 /// <param name="y">Y coord</param> 850 /// <param name="y">Y coord</param>
851 /// <returns>Height at specified coordinates</returns> 851 /// <returns>Height at specified coordinates</returns>
852 public double get(int x, int y) 852 public double get(int x, int y)
853 { 853 {
854 return heightmap.get(x, y); 854 return heightmap.get(x, y);
855 } 855 }
856 856
857 /// <summary> 857 /// <summary>
858 /// Multiplies the heightfield by val 858 /// Multiplies the heightfield by val
859 /// </summary> 859 /// </summary>
860 /// <param name="meep">The heightfield</param> 860 /// <param name="meep">The heightfield</param>
861 /// <param name="val">The multiplier</param> 861 /// <param name="val">The multiplier</param>
862 /// <returns></returns> 862 /// <returns></returns>
863 public static TerrainEngine operator *(TerrainEngine meep, Double val) 863 public static TerrainEngine operator *(TerrainEngine meep, Double val)
864 { 864 {
865 meep.heightmap *= val; 865 meep.heightmap *= val;
866 meep.tainted++; 866 meep.tainted++;
867 return meep; 867 return meep;
868 } 868 }
869 869
870 /// <summary> 870 /// <summary>
871 /// Exports the current heightmap to a PNG file 871 /// Exports the current heightmap to a PNG file
872 /// </summary> 872 /// </summary>
873 /// <param name="filename">The destination filename for the image</param> 873 /// <param name="filename">The destination filename for the image</param>
874 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> 874 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
875 public void exportImage(string filename, string gradientmap) 875 public void exportImage(string filename, string gradientmap)
876 { 876 {
877 try 877 try
878 { 878 {
879 Bitmap gradientmapLd = new Bitmap(gradientmap); 879 Bitmap gradientmapLd = new Bitmap(gradientmap);
880 880
881 int pallete = gradientmapLd.Height; 881 int pallete = gradientmapLd.Height;
882 882
883 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h); 883 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
884 Color[] colours = new Color[pallete]; 884 Color[] colours = new Color[pallete];
885 885
886 for (int i = 0; i < pallete; i++) 886 for (int i = 0; i < pallete; i++)
887 { 887 {
888 colours[i] = gradientmapLd.GetPixel(0, i); 888 colours[i] = gradientmapLd.GetPixel(0, i);
889 } 889 }
890 890
891 Channel copy = heightmap.copy(); 891 Channel copy = heightmap.copy();
892 for (int x = 0; x < copy.w; x++) 892 for (int x = 0; x < copy.w; x++)
893 { 893 {
894 for (int y = 0; y < copy.h; y++) 894 for (int y = 0; y < copy.h; y++)
895 { 895 {
896 // 512 is the largest possible height before colours clamp 896 // 512 is the largest possible height before colours clamp
897 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete); 897 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete);
898 bmp.SetPixel(x, y, colours[colorindex]); 898 bmp.SetPixel(x, y, colours[colorindex]);
899 } 899 }
900 } 900 }
901 901
902 bmp.Save(filename, ImageFormat.Png); 902 bmp.Save(filename, ImageFormat.Png);
903 } 903 }
904 catch (Exception e) 904 catch (Exception e)
905 { 905 {
906 Console.WriteLine("Failed generating terrain map: " + e.ToString()); 906 Console.WriteLine("Failed generating terrain map: " + e.ToString());
907 } 907 }
908 } 908 }
909 909
910 /// <summary> 910 /// <summary>
911 /// Exports the current heightmap in Jpeg2000 format to a byte[] 911 /// Exports the current heightmap in Jpeg2000 format to a byte[]
912 /// </summary> 912 /// </summary>
913 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> 913 /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param>
914 public byte[] exportJpegImage(string gradientmap) 914 public byte[] exportJpegImage(string gradientmap)
915 { 915 {
916 byte[] imageData = null; 916 byte[] imageData = null;
917 try 917 try
918 { 918 {
919 Bitmap gradientmapLd = new Bitmap(gradientmap); 919 Bitmap gradientmapLd = new Bitmap(gradientmap);
920 920
921 int pallete = gradientmapLd.Height; 921 int pallete = gradientmapLd.Height;
922 922
923 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h); 923 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
924 Color[] colours = new Color[pallete]; 924 Color[] colours = new Color[pallete];
925 925
926 for (int i = 0; i < pallete; i++) 926 for (int i = 0; i < pallete; i++)
927 { 927 {
928 colours[i] = gradientmapLd.GetPixel(0, i); 928 colours[i] = gradientmapLd.GetPixel(0, i);
929 } 929 }
930 930
931 Channel copy = heightmap.copy(); 931 Channel copy = heightmap.copy();
932 for (int x = 0; x < copy.w; x++) 932 for (int x = 0; x < copy.w; x++)
933 { 933 {
934 for (int y = 0; y < copy.h; y++) 934 for (int y = 0; y < copy.h; y++)
935 { 935 {
936 // 512 is the largest possible height before colours clamp 936 // 512 is the largest possible height before colours clamp
937 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.h - y, x) / 512.0), 0.0) * pallete); 937 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.h - y, x) / 512.0), 0.0) * pallete);
938 bmp.SetPixel(x, y, colours[colorindex]); 938 bmp.SetPixel(x, y, colours[colorindex]);
939 } 939 }
940 } 940 }
941 941
942 //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png); 942 //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
943 imageData = OpenJPEG.EncodeFromImage(bmp, true ); 943 imageData = OpenJPEG.EncodeFromImage(bmp, true );
944 944
945 } 945 }
946 catch (Exception e) 946 catch (Exception e)
947 { 947 {
948 Console.WriteLine("Failed generating terrain map: " + e.ToString()); 948 Console.WriteLine("Failed generating terrain map: " + e.ToString());
949 } 949 }
950 950
951 return imageData; 951 return imageData;
952 } 952 }
953 } 953 }
954} \ No newline at end of file 954} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
index a38be07..a80ac85 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
@@ -1,126 +1,126 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.CodeDom.Compiler; 29using System.CodeDom.Compiler;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libTerrain; 31using libTerrain;
32using Microsoft.CSharp; 32using Microsoft.CSharp;
33using Microsoft.JScript; 33using Microsoft.JScript;
34 34
35namespace OpenSim.Region.Terrain 35namespace OpenSim.Region.Terrain
36{ 36{
37 public interface ITerrainFilter 37 public interface ITerrainFilter
38 { 38 {
39 void Filter(Channel heightmap, string[] args); 39 void Filter(Channel heightmap, string[] args);
40 string Register(); 40 string Register();
41 string Help(); 41 string Help();
42 } 42 }
43 43
44 public class TestFilter : ITerrainFilter 44 public class TestFilter : ITerrainFilter
45 { 45 {
46 public void Filter(Channel heightmap, string[] args) 46 public void Filter(Channel heightmap, string[] args)
47 { 47 {
48 Console.WriteLine("Hello world"); 48 Console.WriteLine("Hello world");
49 } 49 }
50 50
51 public string Register() 51 public string Register()
52 { 52 {
53 return "demofilter"; 53 return "demofilter";
54 } 54 }
55 55
56 public string Help() 56 public string Help()
57 { 57 {
58 return "demofilter - Does nothing"; 58 return "demofilter - Does nothing";
59 } 59 }
60 } 60 }
61 61
62 public class FilterHost 62 public class FilterHost
63 { 63 {
64 public Dictionary<string, ITerrainFilter> filters = new Dictionary<string, ITerrainFilter>(); 64 public Dictionary<string, ITerrainFilter> filters = new Dictionary<string, ITerrainFilter>();
65 65
66 private void LoadFilter(CodeDomProvider compiler, string filename) 66 private void LoadFilter(CodeDomProvider compiler, string filename)
67 { 67 {
68 CompilerParameters compilerParams = new CompilerParameters(); 68 CompilerParameters compilerParams = new CompilerParameters();
69 CompilerResults compilerResults; 69 CompilerResults compilerResults;
70 compilerParams.GenerateExecutable = false; 70 compilerParams.GenerateExecutable = false;
71 compilerParams.GenerateInMemory = true; 71 compilerParams.GenerateInMemory = true;
72 compilerParams.IncludeDebugInformation = false; 72 compilerParams.IncludeDebugInformation = false;
73 compilerParams.ReferencedAssemblies.Add("libTerrain-BSD.dll"); 73 compilerParams.ReferencedAssemblies.Add("libTerrain-BSD.dll");
74 compilerParams.ReferencedAssemblies.Add("OpenSim.Terrain.BasicTerrain.dll"); 74 compilerParams.ReferencedAssemblies.Add("OpenSim.Terrain.BasicTerrain.dll");
75 compilerParams.ReferencedAssemblies.Add("System.dll"); 75 compilerParams.ReferencedAssemblies.Add("System.dll");
76 76
77 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); 77 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
78 78
79 if (compilerResults.Errors.Count > 0) 79 if (compilerResults.Errors.Count > 0)
80 { 80 {
81 Console.WriteLine("Compile errors:"); 81 Console.WriteLine("Compile errors:");
82 foreach (CompilerError error in compilerResults.Errors) 82 foreach (CompilerError error in compilerResults.Errors)
83 { 83 {
84 Console.WriteLine(error.Line.ToString() + ": " + error.ErrorText.ToString()); 84 Console.WriteLine(error.Line.ToString() + ": " + error.ErrorText.ToString());
85 } 85 }
86 } 86 }
87 else 87 else
88 { 88 {
89 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) 89 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
90 { 90 {
91 Type testInterface = pluginType.GetInterface("ITerrainFilter",true); 91 Type testInterface = pluginType.GetInterface("ITerrainFilter",true);
92 92
93 if (testInterface != null) 93 if (testInterface != null)
94 { 94 {
95 ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); 95 ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
96 96
97 string filterName = filter.Register(); 97 string filterName = filter.Register();
98 Console.WriteLine("Plugin: " + filterName + " loaded."); 98 Console.WriteLine("Plugin: " + filterName + " loaded.");
99 99
100 if (!filters.ContainsKey(filterName)) 100 if (!filters.ContainsKey(filterName))
101 { 101 {
102 filters.Add(filterName, filter); 102 filters.Add(filterName, filter);
103 } 103 }
104 else 104 else
105 { 105 {
106 filters[filterName] = filter; 106 filters[filterName] = filter;
107 } 107 }
108 } 108 }
109 } 109 }
110 } 110 }
111 111
112 } 112 }
113 113
114 public void LoadFilterCSharp(string filename) 114 public void LoadFilterCSharp(string filename)
115 { 115 {
116 CSharpCodeProvider compiler = new CSharpCodeProvider(); 116 CSharpCodeProvider compiler = new CSharpCodeProvider();
117 LoadFilter(compiler, filename); 117 LoadFilter(compiler, filename);
118 } 118 }
119 119
120 public void LoadFilterJScript(string filename) 120 public void LoadFilterJScript(string filename)
121 { 121 {
122 JScriptCodeProvider compiler = new JScriptCodeProvider(); 122 JScriptCodeProvider compiler = new JScriptCodeProvider();
123 LoadFilter(compiler, filename); 123 LoadFilter(compiler, filename);
124 } 124 }
125 } 125 }
126} 126}