aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/LocalAssetServer.cs271
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/LocalGridServer.cs157
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj110
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user12
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build46
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj112
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user12
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build46
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs108
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs210
-rw-r--r--OpenSim/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs297
-rw-r--r--OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj93
-rw-r--r--OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user12
-rw-r--r--OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build42
-rw-r--r--OpenSim/OpenSim.Physics/Manager/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj112
-rw-r--r--OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user12
-rw-r--r--OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build47
-rw-r--r--OpenSim/OpenSim.Physics/Manager/PhysicsActor.cs161
-rw-r--r--OpenSim/OpenSim.Physics/Manager/PhysicsManager.cs116
-rw-r--r--OpenSim/OpenSim.Physics/Manager/PhysicsScene.cs113
-rw-r--r--OpenSim/OpenSim.Physics/Manager/PhysicsVector.cs54
-rw-r--r--OpenSim/OpenSim.Physics/OdePlugin/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs452
-rw-r--r--OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj97
-rw-r--r--OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user12
-rw-r--r--OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build43
-rw-r--r--OpenSim/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj97
-rw-r--r--OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user12
-rw-r--r--OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build43
-rw-r--r--OpenSim/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs449
-rw-r--r--OpenSim/OpenSim.RegionServer/AgentAssetUpload.cs232
-rw-r--r--OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs574
-rw-r--r--OpenSim/OpenSim.RegionServer/Assets/InventoryCache.cs336
-rw-r--r--OpenSim/OpenSim.RegionServer/AuthenticateSessionsBase.cs105
-rw-r--r--OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs31
-rw-r--r--OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs46
-rw-r--r--OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs256
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.Grid.cs167
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs163
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs456
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.cs449
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientViewBase.cs299
-rw-r--r--OpenSim/OpenSim.RegionServer/Grid.cs90
-rw-r--r--OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj258
-rw-r--r--OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user12
-rw-r--r--OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build90
-rw-r--r--OpenSim/OpenSim.RegionServer/OpenSimMain.cs531
-rw-r--r--OpenSim/OpenSim.RegionServer/OpenSimNetworkHandler.cs18
-rw-r--r--OpenSim/OpenSim.RegionServer/PacketServer.cs88
-rw-r--r--OpenSim/OpenSim.RegionServer/RegionInfo.cs261
-rw-r--r--OpenSim/OpenSim.RegionServer/RegionInfoBase.cs32
-rw-r--r--OpenSim/OpenSim.RegionServer/RegionServerBase.cs103
-rw-r--r--OpenSim/OpenSim.RegionServer/UDPServer.cs205
-rw-r--r--OpenSim/OpenSim.RegionServer/VersionInfo.cs37
-rw-r--r--OpenSim/OpenSim.RegionServer/types/Mesh.cs28
-rw-r--r--OpenSim/OpenSim.RegionServer/types/Triangle.cs28
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Avatar.Client.cs33
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs338
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Avatar.cs438
-rw-r--r--OpenSim/OpenSim.RegionServer/world/AvatarAnimations.cs163
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Entity.cs124
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Primitive.cs570
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Primitive2.cs491
-rw-r--r--OpenSim/OpenSim.RegionServer/world/SceneObject.cs77
-rw-r--r--OpenSim/OpenSim.RegionServer/world/World.PacketHandlers.cs368
-rw-r--r--OpenSim/OpenSim.RegionServer/world/World.Scripting.cs124
-rw-r--r--OpenSim/OpenSim.RegionServer/world/World.cs657
-rw-r--r--OpenSim/OpenSim.RegionServer/world/WorldBase.cs176
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/IScriptContext.cs13
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/IScriptEntity.cs19
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/IScriptHandler.cs98
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/Script.cs26
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/ScriptFactory.cs8
-rw-r--r--OpenSim/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs37
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs18
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs476
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Heap.cs16
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs108
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs400
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs141
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs13
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs18
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs19
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Object.cs10
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj153
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user12
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build62
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs134
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Stack.cs15
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs22
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Thread.cs88
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs10
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs10
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs16
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs10
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs10
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs16
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs16
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs95
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj112
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user12
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build46
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs31
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs182
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs16
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj113
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user12
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build47
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs25
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj111
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user12
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build46
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs176
-rw-r--r--OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj99
-rw-r--r--OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj.user12
-rw-r--r--OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build44
-rw-r--r--OpenSim/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs35
-rw-r--r--OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs484
-rw-r--r--OpenSim/OpenSim/Application.cs95
-rw-r--r--OpenSim/OpenSim/OpenSim.csproj147
-rw-r--r--OpenSim/OpenSim/OpenSim.csproj.user13
-rw-r--r--OpenSim/OpenSim/OpenSim.exe.build52
-rw-r--r--OpenSim/OpenSim/OpenSimMain.cs533
130 files changed, 16600 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/AssemblyInfo.cs b/OpenSim/OpenSim.GridInterfaces/Local/AssemblyInfo.cs
new file mode 100644
index 0000000..103b49a
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("LocalGridServers")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("LocalGridServers")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/OpenSim.GridInterfaces/Local/LocalAssetServer.cs
new file mode 100644
index 0000000..5f75821
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/LocalAssetServer.cs
@@ -0,0 +1,271 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using System.IO;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Types;
8using OpenSim.Framework.Utilities;
9using OpenSim.Framework.Console;
10using libsecondlife;
11using Db4objects.Db4o;
12using Db4objects.Db4o.Query;
13
14namespace OpenSim.GridInterfaces.Local
15{
16 public class LocalAssetPlugin : IAssetPlugin
17 {
18 public LocalAssetPlugin()
19 {
20
21 }
22
23 public IAssetServer GetAssetServer()
24 {
25 return (new LocalAssetServer());
26 }
27 }
28
29 public class LocalAssetServer : IAssetServer
30 {
31 private IAssetReceiver _receiver;
32 private BlockingQueue<ARequest> _assetRequests;
33 private IObjectContainer db;
34 private Thread _localAssetServerThread;
35
36 public LocalAssetServer()
37 {
38 bool yapfile;
39 this._assetRequests = new BlockingQueue<ARequest>();
40 yapfile = System.IO.File.Exists("assets.yap");
41
42 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE,"Local Asset Server class created");
43 try
44 {
45 db = Db4oFactory.OpenFile("assets.yap");
46 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE,"Db4 Asset database creation");
47 }
48 catch (Exception e)
49 {
50 db.Close();
51 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM,"Db4 Asset server :Constructor - Exception occured");
52 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, e.ToString());
53 }
54 if (!yapfile)
55 {
56 this.SetUpAssetDatabase();
57 }
58 this._localAssetServerThread = new Thread(new ThreadStart(RunRequests));
59 this._localAssetServerThread.IsBackground = true;
60 this._localAssetServerThread.Start();
61
62 }
63
64 public void SetReceiver(IAssetReceiver receiver)
65 {
66 this._receiver = receiver;
67 }
68
69 public void RequestAsset(LLUUID assetID, bool isTexture)
70 {
71 ARequest req = new ARequest();
72 req.AssetID = assetID;
73 req.IsTexture = isTexture;
74 this._assetRequests.Enqueue(req);
75 }
76
77 public void UpdateAsset(AssetBase asset)
78 {
79
80 }
81
82 public void UploadNewAsset(AssetBase asset)
83 {
84 AssetStorage store = new AssetStorage();
85 store.Data = asset.Data;
86 store.Name = asset.Name;
87 store.UUID = asset.FullID;
88 db.Set(store);
89 db.Commit();
90 }
91
92 public void SetServerInfo(string ServerUrl, string ServerKey)
93 {
94
95 }
96 public void Close()
97 {
98 if (db != null)
99 {
100 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "Closing local asset server database");
101 db.Close();
102 }
103 }
104
105 private void RunRequests()
106 {
107 while (true)
108 {
109 byte[] idata = null;
110 bool found = false;
111 AssetStorage foundAsset = null;
112 ARequest req = this._assetRequests.Dequeue();
113 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
114 if (result.Count > 0)
115 {
116 foundAsset = (AssetStorage)result.Next();
117 found = true;
118 }
119
120 AssetBase asset = new AssetBase();
121 if (found)
122 {
123 asset.FullID = foundAsset.UUID;
124 asset.Type = foundAsset.Type;
125 asset.InvType = foundAsset.Type;
126 asset.Name = foundAsset.Name;
127 idata = foundAsset.Data;
128 }
129 else
130 {
131 asset.FullID = LLUUID.Zero;
132 }
133 asset.Data = idata;
134 _receiver.AssetReceived(asset, req.IsTexture);
135 }
136
137 }
138
139 private void SetUpAssetDatabase()
140 {
141 try
142 {
143
144 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "Setting up asset database");
145
146 AssetBase Image = new AssetBase();
147 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
148 Image.Name = "Bricks";
149 this.LoadAsset(Image, true, "bricks.jp2");
150 AssetStorage store = new AssetStorage();
151 store.Data = Image.Data;
152 store.Name = Image.Name;
153 store.UUID = Image.FullID;
154 db.Set(store);
155 db.Commit();
156
157 Image = new AssetBase();
158 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
159 Image.Name = "Plywood";
160 this.LoadAsset(Image, true, "plywood.jp2");
161 store = new AssetStorage();
162 store.Data = Image.Data;
163 store.Name = Image.Name;
164 store.UUID = Image.FullID;
165 db.Set(store);
166 db.Commit();
167
168 Image = new AssetBase();
169 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
170 Image.Name = "Rocks";
171 this.LoadAsset(Image, true, "rocks.jp2");
172 store = new AssetStorage();
173 store.Data = Image.Data;
174 store.Name = Image.Name;
175 store.UUID = Image.FullID;
176 db.Set(store);
177 db.Commit();
178
179 Image = new AssetBase();
180 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
181 Image.Name = "Granite";
182 this.LoadAsset(Image, true, "granite.jp2");
183 store = new AssetStorage();
184 store.Data = Image.Data;
185 store.Name = Image.Name;
186 store.UUID = Image.FullID;
187 db.Set(store);
188 db.Commit();
189
190 Image = new AssetBase();
191 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
192 Image.Name = "Hardwood";
193 this.LoadAsset(Image, true, "hardwood.jp2");
194 store = new AssetStorage();
195 store.Data = Image.Data;
196 store.Name = Image.Name;
197 store.UUID = Image.FullID;
198 db.Set(store);
199 db.Commit();
200
201 Image = new AssetBase();
202 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
203 Image.Name = "Prim Base Texture";
204 this.LoadAsset(Image, true, "plywood.jp2");
205 store = new AssetStorage();
206 store.Data = Image.Data;
207 store.Name = Image.Name;
208 store.UUID = Image.FullID;
209 db.Set(store);
210 db.Commit();
211
212 Image = new AssetBase();
213 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006");
214 Image.Name = "Map Base Texture";
215 this.LoadAsset(Image, true, "map_base.jp2");
216 store = new AssetStorage();
217 store.Data = Image.Data;
218 store.Name = Image.Name;
219 store.UUID = Image.FullID;
220 db.Set(store);
221 db.Commit();
222
223 Image = new AssetBase();
224 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007");
225 Image.Name = "Map Texture";
226 this.LoadAsset(Image, true, "map1.jp2");
227 store = new AssetStorage();
228 store.Data = Image.Data;
229 store.Name = Image.Name;
230 store.UUID = Image.FullID;
231 db.Set(store);
232 db.Commit();
233
234 Image = new AssetBase();
235 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
236 Image.Name = "Shape";
237 this.LoadAsset(Image, false, "base_shape.dat");
238 store = new AssetStorage();
239 store.Data = Image.Data;
240 store.Name = Image.Name;
241 store.UUID = Image.FullID;
242 db.Set(store);
243 db.Commit();
244 }
245 catch (Exception e)
246 {
247 Console.WriteLine(e.Message);
248 }
249
250 }
251
252 private void LoadAsset(AssetBase info, bool image, string filename)
253 {
254 //should request Asset from storage manager
255 //but for now read from file
256
257 string dataPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
258 string fileName = Path.Combine(dataPath, filename);
259 FileInfo fInfo = new FileInfo(fileName);
260 long numBytes = fInfo.Length;
261 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
262 byte[] idata = new byte[numBytes];
263 BinaryReader br = new BinaryReader(fStream);
264 idata = br.ReadBytes((int)numBytes);
265 br.Close();
266 fStream.Close();
267 info.Data = idata;
268 //info.loaded=true;
269 }
270 }
271}
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/LocalGridServer.cs b/OpenSim/OpenSim.GridInterfaces/Local/LocalGridServer.cs
new file mode 100644
index 0000000..fdd6ba4
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/LocalGridServer.cs
@@ -0,0 +1,157 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using System.Threading;
30using System.IO;
31using OpenSim.Framework.Interfaces;
32using OpenSim.Framework.Types;
33using OpenSim.Framework.Console;
34using libsecondlife;
35using Db4objects.Db4o;
36using Db4objects.Db4o.Query;
37using System.Collections;
38
39namespace OpenSim.GridInterfaces.Local
40{
41 /// <summary>
42 ///
43 /// </summary>
44 ///
45 public class LocalGridPlugin : IGridPlugin
46 {
47 public LocalGridPlugin()
48 {
49
50 }
51
52 public IGridServer GetGridServer()
53 {
54 return(new LocalGridServer());
55 }
56 }
57
58 public class LocalGridServer : LocalGridBase
59 {
60 public List<Login> Sessions = new List<Login>();
61
62 public LocalGridServer()
63 {
64 Sessions = new List<Login>();
65 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE,"Local Grid Server class created");
66 }
67
68 public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
69 {
70 return true;
71 }
72
73 public override string GetName()
74 {
75 return "Local";
76 }
77
78 public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
79 {
80 //we are running local
81 AuthenticateResponse user = new AuthenticateResponse();
82
83 lock(this.Sessions)
84 {
85
86 for(int i = 0; i < Sessions.Count; i++)
87 {
88 if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
89 {
90 user.Authorised = true;
91 user.LoginInfo = Sessions[i];
92 }
93 }
94 }
95 return(user);
96 }
97
98 public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
99 {
100 return(true);
101 }
102
103 public override UUIDBlock RequestUUIDBlock()
104 {
105 UUIDBlock uuidBlock = new UUIDBlock();
106 return(uuidBlock);
107 }
108
109 public override NeighbourInfo[] RequestNeighbours()
110 {
111 return null;
112 }
113
114 public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
115 {
116
117 }
118
119 public override IList RequestMapBlocks(int minX, int minY, int maxX, int maxY)
120 {
121 return new ArrayList();
122 }
123
124
125 public override void Close()
126 {
127
128 }
129
130 /// <summary>
131 /// used by the local login server to inform us of new sessions
132 /// </summary>
133 /// <param name="session"></param>
134 public override void AddNewSession(Login session)
135 {
136 lock(this.Sessions)
137 {
138 this.Sessions.Add(session);
139 }
140 }
141 }
142
143 public class AssetUUIDQuery : Predicate
144 {
145 private LLUUID _findID;
146
147 public AssetUUIDQuery(LLUUID find)
148 {
149 _findID = find;
150 }
151 public bool Match(AssetStorage asset)
152 {
153 return (asset.UUID == _findID);
154 }
155 }
156
157}
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj
new file mode 100644
index 0000000..c6ec476
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj
@@ -0,0 +1,110 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{546099CD-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.GridInterfaces.Local</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.GridInterfaces.Local</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="Db4objects.Db4o.dll" >
70 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="libsecondlife.dll" >
74 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="AssemblyInfo.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="LocalAssetServer.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="LocalGridServer.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 </ItemGroup>
103 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
104 <PropertyGroup>
105 <PreBuildEvent>
106 </PreBuildEvent>
107 <PostBuildEvent>
108 </PostBuildEvent>
109 </PropertyGroup>
110</Project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build
new file mode 100644
index 0000000..fc2d94b
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Local/OpenSim.GridInterfaces.Local.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.GridInterfaces.Local" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.GridInterfaces.Local" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="LocalAssetServer.cs" />
16 <include name="LocalGridServer.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="System.dll" />
24 <include name="System.Xml.dll" />
25 <include name="../../../bin/Db4objects.Db4o.dll" />
26 <include name="../../../bin/libsecondlife.dll" />
27 <include name="../../../bin/OpenSim.Framework.dll" />
28 <include name="../../../bin/OpenSim.Framework.Console.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs b/OpenSim/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs
new file mode 100644
index 0000000..0fa7d6e
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("RemoteGridServers")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("RemoteGridServers")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj
new file mode 100644
index 0000000..28e0bb8
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj
@@ -0,0 +1,112 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{B55C0B5D-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.GridInterfaces.Remote</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.GridInterfaces.Remote</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
82 <Name>OpenSim.Framework.Console</Name>
83 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 <ProjectReference Include="..\..\..\Common\XmlRpcCS\XMLRPC.csproj">
88 <Name>XMLRPC</Name>
89 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 </ItemGroup>
94 <ItemGroup>
95 <Compile Include="AssemblyInfo.cs">
96 <SubType>Code</SubType>
97 </Compile>
98 <Compile Include="RemoteAssetServer.cs">
99 <SubType>Code</SubType>
100 </Compile>
101 <Compile Include="RemoteGridServer.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 </ItemGroup>
105 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
106 <PropertyGroup>
107 <PreBuildEvent>
108 </PreBuildEvent>
109 <PostBuildEvent>
110 </PostBuildEvent>
111 </PropertyGroup>
112</Project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build
new file mode 100644
index 0000000..daf35c6
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/OpenSim.GridInterfaces.Remote.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.GridInterfaces.Remote" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.GridInterfaces.Remote" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="RemoteAssetServer.cs" />
16 <include name="RemoteGridServer.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="System.dll" />
24 <include name="System.Xml.dll" />
25 <include name="../../../bin/libsecondlife.dll" />
26 <include name="../../../bin/OpenSim.Framework.dll" />
27 <include name="../../../bin/OpenSim.Framework.Console.dll" />
28 <include name="../../../bin/XMLRPC.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs
new file mode 100644
index 0000000..7432dee
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs
@@ -0,0 +1,108 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.IO;
8using libsecondlife;
9using OpenSim.Framework.Interfaces;
10using OpenSim.Framework.Types;
11using OpenSim.Framework.Utilities;
12
13namespace OpenSim.GridInterfaces.Remote
14{
15 public class RemoteAssetServer : IAssetServer
16 {
17 private IAssetReceiver _receiver;
18 private BlockingQueue<ARequest> _assetRequests;
19 private Thread _remoteAssetServerThread;
20 private string AssetServerUrl;
21 private string AssetSendKey;
22
23 public RemoteAssetServer()
24 {
25 this._assetRequests = new BlockingQueue<ARequest>();
26 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
27 this._remoteAssetServerThread.IsBackground = true;
28 this._remoteAssetServerThread.Start();
29 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Remote Asset Server class created");
30 }
31
32 public void SetReceiver(IAssetReceiver receiver)
33 {
34 this._receiver = receiver;
35 }
36
37 public void RequestAsset(LLUUID assetID, bool isTexture)
38 {
39 ARequest req = new ARequest();
40 req.AssetID = assetID;
41 req.IsTexture = isTexture;
42 this._assetRequests.Enqueue(req);
43 }
44
45 public void UpdateAsset(AssetBase asset)
46 {
47
48 }
49
50 public void UploadNewAsset(AssetBase asset)
51 {
52 Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
53 string ret = Windows1252Encoding.GetString(asset.Data);
54 byte[] buffer = Windows1252Encoding.GetBytes(ret);
55 WebClient client = new WebClient();
56 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer);
57
58 }
59
60 public void SetServerInfo(string ServerUrl, string ServerKey)
61 {
62 this.AssetServerUrl = ServerUrl;
63 this.AssetSendKey = ServerKey;
64 }
65
66 private void RunRequests()
67 {
68 while (true)
69 {
70 //we need to add support for the asset server not knowing about a requested asset
71 // 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
72 ARequest req = this._assetRequests.Dequeue();
73 LLUUID assetID = req.AssetID;
74 // OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW," RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID);
75 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID);
76 WebResponse AssetResponse = AssetLoad.GetResponse();
77 byte[] idata = new byte[(int)AssetResponse.ContentLength];
78 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
79 idata = br.ReadBytes((int)AssetResponse.ContentLength);
80 br.Close();
81
82 AssetBase asset = new AssetBase();
83 asset.FullID = assetID;
84 asset.Data = idata;
85 _receiver.AssetReceived(asset, req.IsTexture);
86 }
87 }
88
89 public void Close()
90 {
91
92 }
93 }
94
95 public class RemoteAssetPlugin : IAssetPlugin
96 {
97 public RemoteAssetPlugin()
98 {
99
100 }
101
102 public IAssetServer GetAssetServer()
103 {
104 return (new RemoteAssetServer());
105 }
106 }
107
108}
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs b/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
new file mode 100644
index 0000000..7f911d8
--- /dev/null
+++ b/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
@@ -0,0 +1,210 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Threading;
31using System.Net;
32using System.Net.Sockets;
33using System.IO;
34using libsecondlife;
35using Nwc.XmlRpc;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38
39namespace OpenSim.GridInterfaces.Remote
40{
41 public class RemoteGridServer : RemoteGridBase
42 {
43 private string GridServerUrl;
44 private string GridSendKey;
45 private string GridRecvKey;
46 private Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
47 private ArrayList simneighbours = new ArrayList();
48 private Hashtable griddatahash;
49
50 public override Dictionary<uint, AgentCircuitData> agentcircuits
51 {
52 get { return AgentCircuits; }
53 set { AgentCircuits = value; }
54 }
55
56 public override ArrayList neighbours
57 {
58 get { return simneighbours; }
59 set { simneighbours = value; }
60 }
61
62 public override Hashtable GridData
63 {
64 get { return griddatahash; }
65 set { griddatahash = value; }
66 }
67
68
69 public RemoteGridServer()
70 {
71 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Remote Grid Server class created");
72 }
73
74 public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
75 {
76 Hashtable GridParams = new Hashtable();
77 GridParams["authkey"] = GridSendKey;
78 GridParams["UUID"] = SimUUID.ToString();
79 GridParams["sim_ip"] = sim_ip;
80 GridParams["sim_port"] = sim_port.ToString();
81 ArrayList SendParams = new ArrayList();
82 SendParams.Add(GridParams);
83
84 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
85 XmlRpcResponse GridResp = GridReq.Send(this.GridServerUrl, 3000);
86 Hashtable GridRespData = (Hashtable)GridResp.Value;
87 this.griddatahash = GridRespData;
88
89 if (GridRespData.ContainsKey("error"))
90 {
91 string errorstring = (string)GridRespData["error"];
92 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Error connecting to grid:");
93 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, errorstring);
94 return false;
95 }
96 this.neighbours = (ArrayList)GridRespData["neighbours"];
97 Console.WriteLine(simneighbours.Count);
98 return true;
99 }
100
101 public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
102 {
103 AgentCircuitData validcircuit = null;
104 if (this.AgentCircuits.ContainsKey(circuitcode))
105 {
106 validcircuit = this.AgentCircuits[circuitcode];
107 }
108 AuthenticateResponse user = new AuthenticateResponse();
109 if (validcircuit == null)
110 {
111 //don't have this circuit code in our list
112 user.Authorised = false;
113 return (user);
114 }
115
116 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
117 {
118 // YAY! Valid login
119 user.Authorised = true;
120 user.LoginInfo = new Login();
121 user.LoginInfo.Agent = agentID;
122 user.LoginInfo.Session = sessionID;
123 user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
124 user.LoginInfo.First = validcircuit.firstname;
125 user.LoginInfo.Last = validcircuit.lastname;
126 }
127 else
128 {
129 // Invalid
130 user.Authorised = false;
131 }
132
133 return (user);
134 }
135
136 public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
137 {
138 WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString());
139 DeleteSession.Method = "DELETE";
140 DeleteSession.ContentType = "text/plaintext";
141 DeleteSession.ContentLength = 0;
142
143 StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII);
144 stOut.Write("");
145 stOut.Close();
146
147 StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream());
148 string GridResponse = stIn.ReadToEnd();
149 stIn.Close();
150 return (true);
151 }
152
153 public override UUIDBlock RequestUUIDBlock()
154 {
155 UUIDBlock uuidBlock = new UUIDBlock();
156 return (uuidBlock);
157 }
158
159 public override NeighbourInfo[] RequestNeighbours()
160 {
161 return null;
162 }
163
164 public override IList RequestMapBlocks(int minX, int minY, int maxX, int maxY)
165 {
166 Hashtable param = new Hashtable();
167 param["xmin"] = minX;
168 param["ymin"] = minY;
169 param["xmax"] = maxX;
170 param["ymax"] = maxY;
171 IList parameters = new ArrayList();
172 parameters.Add(param);
173 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
174 XmlRpcResponse resp = req.Send(GridServerUrl, 3000);
175 Hashtable respData = (Hashtable)resp.Value;
176 return (IList)respData["sim-profiles"];
177 }
178
179 public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
180 {
181 this.GridServerUrl = ServerUrl;
182 this.GridSendKey = SendKey;
183 this.GridRecvKey = RecvKey;
184 }
185
186 public override string GetName()
187 {
188 return "Remote";
189 }
190
191 public override void Close()
192 {
193
194 }
195 }
196
197 public class RemoteGridPlugin : IGridPlugin
198 {
199 public RemoteGridPlugin()
200 {
201
202 }
203
204 public IGridServer GetGridServer()
205 {
206 return (new RemoteGridServer());
207 }
208 }
209
210}
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..0c9c06c
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("PhysXplugin")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("PhysXplugin")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
new file mode 100644
index 0000000..54be853
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -0,0 +1,297 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using OpenSim.Physics.Manager;
30
31namespace OpenSim.Physics.BasicPhysicsPlugin
32{
33 /// <summary>
34 /// Will be the PhysX plugin but for now will be a very basic physics engine
35 /// </summary>
36 public class BasicPhysicsPlugin : IPhysicsPlugin
37 {
38 private BasicScene _mScene;
39
40 public BasicPhysicsPlugin()
41 {
42
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene()
51 {
52 if(_mScene == null)
53 {
54 _mScene = new BasicScene();
55 }
56 return(_mScene);
57 }
58
59 public string GetName()
60 {
61 return("basicphysics");
62 }
63
64 public void Dispose()
65 {
66
67 }
68 }
69
70 public class BasicScene :PhysicsScene
71 {
72 private List<BasicActor> _actors = new List<BasicActor>();
73 private float[] _heightMap;
74
75 public BasicScene()
76 {
77
78 }
79
80 public override PhysicsActor AddAvatar(PhysicsVector position)
81 {
82 BasicActor act = new BasicActor();
83 act.Position = position;
84 _actors.Add(act);
85 return act;
86 }
87
88 public override void RemoveAvatar(PhysicsActor actor)
89 {
90 BasicActor act = (BasicActor)actor;
91 if(_actors.Contains(act))
92 {
93 _actors.Remove(act);
94 }
95
96 }
97
98 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
99 {
100 return null;
101 }
102
103 public override void Simulate(float timeStep)
104 {
105 foreach (BasicActor actor in _actors)
106 {
107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
109 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
110 /*if(actor.Flying)
111 {
112 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
113 }
114 else
115 {
116 actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep);
117 }
118 if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1))
119 {*/
120 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
121 {
122 actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1;
123 }
124 else
125 {
126 if (actor.Position.Y < -1)
127 {
128 actor.Position.Y = -1;
129 }
130 else if (actor.Position.Y > 257)
131 {
132 actor.Position.Y = 257;
133 }
134
135 if (actor.Position.X < -1)
136 {
137 actor.Position.X = -1;
138 }
139 if (actor.Position.X > 257)
140 {
141 actor.Position.X = 257;
142 }
143 }
144 //}
145
146
147
148 // This code needs sorting out - border crossings etc
149/* if(actor.Position.X<0)
150 {
151 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
152 actor.Position.X = 0;
153 actor.Velocity.X = 0;
154 }
155 if(actor.Position.Y < 0)
156 {
157 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
158 actor.Position.Y = 0;
159 actor.Velocity.Y = 0;
160 }
161 if(actor.Position.X > 255)
162 {
163 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
164 actor.Position.X = 255;
165 actor.Velocity.X = 0;
166 }
167 if(actor.Position.Y > 255)
168 {
169 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
170 actor.Position.Y = 255;
171 actor.Velocity.X = 0;
172 }*/
173 }
174 }
175
176 public override void GetResults()
177 {
178
179 }
180
181 public override bool IsThreaded
182 {
183 get
184 {
185 return(false); // for now we won't be multithreaded
186 }
187 }
188
189 public override void SetTerrain(float[] heightMap)
190 {
191 this._heightMap = heightMap;
192 }
193
194 public override void DeleteTerrain()
195 {
196
197 }
198 }
199
200 public class BasicActor : PhysicsActor
201 {
202 private PhysicsVector _position;
203 private PhysicsVector _velocity;
204 private PhysicsVector _acceleration;
205 private bool flying;
206 public BasicActor()
207 {
208 _velocity = new PhysicsVector();
209 _position = new PhysicsVector();
210 _acceleration = new PhysicsVector();
211 }
212
213 public override bool Flying
214 {
215 get
216 {
217 return false;
218 }
219 set
220 {
221 flying= value;
222 }
223 }
224
225 public override PhysicsVector Position
226 {
227 get
228 {
229 return _position;
230 }
231 set
232 {
233 _position = value;
234 }
235 }
236
237 public override PhysicsVector Velocity
238 {
239 get
240 {
241 return _velocity;
242 }
243 set
244 {
245 _velocity = value;
246 }
247 }
248
249 public override Axiom.MathLib.Quaternion Orientation
250 {
251 get
252 {
253 return Axiom.MathLib.Quaternion.Identity;
254 }
255 set
256 {
257
258 }
259 }
260
261 public override PhysicsVector Acceleration
262 {
263 get
264 {
265 return _acceleration;
266 }
267
268 }
269
270 public override bool Kinematic
271 {
272 get
273 {
274 return true;
275 }
276 set
277 {
278
279 }
280 }
281 public void SetAcceleration (PhysicsVector accel)
282 {
283 this._acceleration = accel;
284 }
285
286 public override void AddForce(PhysicsVector force)
287 {
288
289 }
290
291 public override void SetMomentum(PhysicsVector momentum)
292 {
293
294 }
295 }
296
297}
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj
new file mode 100644
index 0000000..15f3f72
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj
@@ -0,0 +1,93 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{4F874463-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Physics.BasicPhysicsPlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Physics.BasicPhysicsPlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Axiom.MathLib.dll" >
66 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 </ItemGroup>
70 <ItemGroup>
71 <ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
72 <Name>OpenSim.Physics.Manager</Name>
73 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
74 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
75 <Private>False</Private>
76 </ProjectReference>
77 </ItemGroup>
78 <ItemGroup>
79 <Compile Include="AssemblyInfo.cs">
80 <SubType>Code</SubType>
81 </Compile>
82 <Compile Include="BasicPhysicsPlugin.cs">
83 <SubType>Code</SubType>
84 </Compile>
85 </ItemGroup>
86 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
87 <PropertyGroup>
88 <PreBuildEvent>
89 </PreBuildEvent>
90 <PostBuildEvent>
91 </PostBuildEvent>
92 </PropertyGroup>
93</Project>
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build
new file mode 100644
index 0000000..5845387
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/OpenSim.Physics.BasicPhysicsPlugin.dll.build
@@ -0,0 +1,42 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Physics.BasicPhysicsPlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Physics.BasicPhysicsPlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="BasicPhysicsPlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="../../../bin/Axiom.MathLib.dll" />
24 <include name="../../../bin/OpenSim.Physics.Manager.dll" />
25 </references>
26 </csc>
27 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/Physics/" />
28 <mkdir dir="${project::get-base-directory()}/../../../bin/Physics/"/>
29 <copy todir="${project::get-base-directory()}/../../../bin/Physics/">
30 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
31 <include name="*.dll"/>
32 <include name="*.exe"/>
33 </fileset>
34 </copy>
35 </target>
36 <target name="clean">
37 <delete dir="${bin.dir}" failonerror="false" />
38 <delete dir="${obj.dir}" failonerror="false" />
39 </target>
40 <target name="doc" description="Creates documentation.">
41 </target>
42</project>
diff --git a/OpenSim/OpenSim.Physics/Manager/AssemblyInfo.cs b/OpenSim/OpenSim.Physics/Manager/AssemblyInfo.cs
new file mode 100644
index 0000000..57a8913
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("PhysicsManager")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("PhysicsManager")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj
new file mode 100644
index 0000000..70ffa30
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj
@@ -0,0 +1,112 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{8BE16150-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Physics.Manager</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Physics.Manager</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="Axiom.MathLib.dll" >
70 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
82 <Name>OpenSim.Framework.Console</Name>
83 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 </ItemGroup>
88 <ItemGroup>
89 <Compile Include="AssemblyInfo.cs">
90 <SubType>Code</SubType>
91 </Compile>
92 <Compile Include="PhysicsActor.cs">
93 <SubType>Code</SubType>
94 </Compile>
95 <Compile Include="PhysicsManager.cs">
96 <SubType>Code</SubType>
97 </Compile>
98 <Compile Include="PhysicsScene.cs">
99 <SubType>Code</SubType>
100 </Compile>
101 <Compile Include="PhysicsVector.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 </ItemGroup>
105 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
106 <PropertyGroup>
107 <PreBuildEvent>
108 </PreBuildEvent>
109 <PostBuildEvent>
110 </PostBuildEvent>
111 </PropertyGroup>
112</Project>
diff --git a/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build
new file mode 100644
index 0000000..726444a
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/OpenSim.Physics.Manager.dll.build
@@ -0,0 +1,47 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Physics.Manager" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Physics.Manager" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="PhysicsActor.cs" />
16 <include name="PhysicsManager.cs" />
17 <include name="PhysicsScene.cs" />
18 <include name="PhysicsVector.cs" />
19 </sources>
20 <references basedir="${project::get-base-directory()}">
21 <lib>
22 <include name="${project::get-base-directory()}" />
23 <include name="${project::get-base-directory()}/${build.dir}" />
24 </lib>
25 <include name="System.dll" />
26 <include name="System.Xml.dll" />
27 <include name="../../../bin/Axiom.MathLib.dll" />
28 <include name="../../../bin/OpenSim.Framework.dll" />
29 <include name="../../../bin/OpenSim.Framework.Console.dll" />
30 </references>
31 </csc>
32 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
33 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
34 <copy todir="${project::get-base-directory()}/../../../bin/">
35 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
36 <include name="*.dll"/>
37 <include name="*.exe"/>
38 </fileset>
39 </copy>
40 </target>
41 <target name="clean">
42 <delete dir="${bin.dir}" failonerror="false" />
43 <delete dir="${obj.dir}" failonerror="false" />
44 </target>
45 <target name="doc" description="Creates documentation.">
46 </target>
47</project>
diff --git a/OpenSim/OpenSim.Physics/Manager/PhysicsActor.cs b/OpenSim/OpenSim.Physics/Manager/PhysicsActor.cs
new file mode 100644
index 0000000..a0b6c21
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/PhysicsActor.cs
@@ -0,0 +1,161 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Physics.Manager
33{
34 public abstract class PhysicsActor
35 {
36 public static PhysicsActor Null
37 {
38 get
39 {
40 return new NullPhysicsActor();
41 }
42 }
43
44 public abstract PhysicsVector Position
45 {
46 get;
47 set;
48 }
49
50 public abstract PhysicsVector Velocity
51 {
52 get;
53 set;
54 }
55
56 public abstract PhysicsVector Acceleration
57 {
58 get;
59 }
60
61 public abstract Axiom.MathLib.Quaternion Orientation
62 {
63 get;
64 set;
65 }
66
67 public abstract bool Flying
68 {
69 get;
70 set;
71 }
72
73 public abstract bool Kinematic
74 {
75 get;
76 set;
77 }
78
79 public abstract void AddForce(PhysicsVector force);
80
81 public abstract void SetMomentum(PhysicsVector momentum);
82 }
83
84 public class NullPhysicsActor : PhysicsActor
85 {
86 public override PhysicsVector Position
87 {
88 get
89 {
90 return PhysicsVector.Zero;
91 }
92 set
93 {
94 return;
95 }
96 }
97
98 public override PhysicsVector Velocity
99 {
100 get
101 {
102 return PhysicsVector.Zero;
103 }
104 set
105 {
106 return;
107 }
108 }
109
110 public override Axiom.MathLib.Quaternion Orientation
111 {
112 get
113 {
114 return Axiom.MathLib.Quaternion.Identity;
115 }
116 set
117 {
118
119 }
120 }
121
122 public override PhysicsVector Acceleration
123 {
124 get { return PhysicsVector.Zero; }
125 }
126
127 public override bool Flying
128 {
129 get
130 {
131 return false;
132 }
133 set
134 {
135 return;
136 }
137 }
138
139 public override bool Kinematic
140 {
141 get
142 {
143 return true;
144 }
145 set
146 {
147 return;
148 }
149 }
150
151 public override void AddForce(PhysicsVector force)
152 {
153 return;
154 }
155
156 public override void SetMomentum(PhysicsVector momentum)
157 {
158 return;
159 }
160 }
161}
diff --git a/OpenSim/OpenSim.Physics/Manager/PhysicsManager.cs b/OpenSim/OpenSim.Physics/Manager/PhysicsManager.cs
new file mode 100644
index 0000000..291fc7e
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/PhysicsManager.cs
@@ -0,0 +1,116 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using System.Collections;
30using System.IO;
31using System.Reflection;
32using Axiom.MathLib;
33using OpenSim.Framework.Console;
34
35namespace OpenSim.Physics.Manager
36{
37 /// <summary>
38 /// Description of MyClass.
39 /// </summary>
40 public class PhysicsManager
41 {
42 private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
43
44 public PhysicsManager()
45 {
46
47 }
48
49 public PhysicsScene GetPhysicsScene(string engineName)
50 {
51 if (String.IsNullOrEmpty(engineName))
52 {
53 return new NullPhysicsScene();
54 }
55
56 if(_plugins.ContainsKey(engineName))
57 {
58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
59 return _plugins[engineName].GetScene();
60 }
61 else
62 {
63 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
64 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
65 }
66 }
67
68 public void LoadPlugins()
69 {
70 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
71 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
72
73
74 for(int i= 0; i<pluginFiles.Length; i++)
75 {
76 this.AddPlugin(pluginFiles[i]);
77 }
78 }
79
80 private void AddPlugin(string FileName)
81 {
82 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
83
84 foreach (Type pluginType in pluginAssembly.GetTypes())
85 {
86 if (pluginType.IsPublic)
87 {
88 if (!pluginType.IsAbstract)
89 {
90 Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
91
92 if (typeInterface != null)
93 {
94 IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
95 plug.Init();
96 this._plugins.Add(plug.GetName(),plug);
97
98 }
99
100 typeInterface = null;
101 }
102 }
103 }
104
105 pluginAssembly = null;
106 }
107 }
108
109 public interface IPhysicsPlugin
110 {
111 bool Init();
112 PhysicsScene GetScene();
113 string GetName();
114 void Dispose();
115 }
116}
diff --git a/OpenSim/OpenSim.Physics/Manager/PhysicsScene.cs b/OpenSim/OpenSim.Physics/Manager/PhysicsScene.cs
new file mode 100644
index 0000000..7dab4e1
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/PhysicsScene.cs
@@ -0,0 +1,113 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Console;
32
33namespace OpenSim.Physics.Manager
34{
35 public abstract class PhysicsScene
36 {
37 public static PhysicsScene Null
38 {
39 get
40 {
41 return new NullPhysicsScene();
42 }
43 }
44
45 public abstract PhysicsActor AddAvatar(PhysicsVector position);
46
47 public abstract void RemoveAvatar(PhysicsActor actor);
48
49 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
50
51 public abstract void Simulate(float timeStep);
52
53 public abstract void GetResults();
54
55 public abstract void SetTerrain(float[] heightMap);
56
57 public abstract void DeleteTerrain();
58
59 public abstract bool IsThreaded
60 {
61 get;
62 }
63 }
64
65 public class NullPhysicsScene : PhysicsScene
66 {
67 private static int m_workIndicator;
68
69 public override PhysicsActor AddAvatar(PhysicsVector position)
70 {
71 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE,"NullPhysicsScene : AddAvatar({0})", position);
72 return PhysicsActor.Null;
73 }
74
75 public override void RemoveAvatar(PhysicsActor actor)
76 {
77
78 }
79
80 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
81 {
82 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : AddPrim({0},{1})", position, size);
83 return PhysicsActor.Null;
84 }
85
86 public override void Simulate(float timeStep)
87 {
88 m_workIndicator = (m_workIndicator + 1) % 10;
89
90 //OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString());
91 }
92
93 public override void GetResults()
94 {
95 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : GetResults()");
96 }
97
98 public override void SetTerrain(float[] heightMap)
99 {
100 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
101 }
102
103 public override void DeleteTerrain()
104 {
105
106 }
107
108 public override bool IsThreaded
109 {
110 get { return false; }
111 }
112 }
113}
diff --git a/OpenSim/OpenSim.Physics/Manager/PhysicsVector.cs b/OpenSim/OpenSim.Physics/Manager/PhysicsVector.cs
new file mode 100644
index 0000000..3c824d0
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/Manager/PhysicsVector.cs
@@ -0,0 +1,54 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Physics.Manager
33{
34 public class PhysicsVector
35 {
36 public float X;
37 public float Y;
38 public float Z;
39
40 public PhysicsVector()
41 {
42
43 }
44
45 public PhysicsVector(float x, float y, float z)
46 {
47 X = x;
48 Y = y;
49 Z = z;
50 }
51
52 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
53 }
54}
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/OpenSim.Physics/OdePlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..913aae7
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/OdePlugin/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("RealPhysXplugin")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("RealPhysXplugin")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs
new file mode 100644
index 0000000..599dea8
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs
@@ -0,0 +1,452 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using OpenSim.Physics.Manager;
30using Ode.NET;
31
32namespace OpenSim.Physics.OdePlugin
33{
34 /// <summary>
35 /// ODE plugin
36 /// </summary>
37 public class OdePlugin : IPhysicsPlugin
38 {
39 private OdeScene _mScene;
40
41 public OdePlugin()
42 {
43
44 }
45
46 public bool Init()
47 {
48 return true;
49 }
50
51 public PhysicsScene GetScene()
52 {
53 if (_mScene == null)
54 {
55 _mScene = new OdeScene();
56 }
57 return (_mScene);
58 }
59
60 public string GetName()
61 {
62 return ("OpenDynamicsEngine");
63 }
64
65 public void Dispose()
66 {
67
68 }
69 }
70
71 public class OdeScene : PhysicsScene
72 {
73 static public IntPtr world;
74 static public IntPtr space;
75 static private IntPtr contactgroup;
76 static private IntPtr LandGeom;
77 //static private IntPtr Land;
78 private double[] _heightmap;
79 static private d.NearCallback nearCallback = near;
80 private List<OdeCharacter> _characters = new List<OdeCharacter>();
81 private static d.ContactGeom[] contacts = new d.ContactGeom[30];
82 private static d.Contact contact;
83
84 public OdeScene()
85 {
86 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
87 contact.surface.mu = d.Infinity;
88 contact.surface.mu2 = 0.0f;
89 contact.surface.bounce = 0.1f;
90 contact.surface.bounce_vel = 0.1f;
91 contact.surface.soft_cfm = 0.01f;
92
93 world = d.WorldCreate();
94 space = d.HashSpaceCreate(IntPtr.Zero);
95 contactgroup = d.JointGroupCreate(0);
96 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
97 //d.WorldSetCFM(world, 1e-5f);
98 d.WorldSetAutoDisableFlag(world, false);
99 d.WorldSetContactSurfaceLayer(world, 0.001f);
100 // d.CreatePlane(space, 0, 0, 1, 0);
101 this._heightmap = new double[65536];
102 }
103
104 // This function blatantly ripped off from BoxStack.cs
105 static private void near(IntPtr space, IntPtr g1, IntPtr g2)
106 {
107 //Console.WriteLine("collision callback");
108 IntPtr b1 = d.GeomGetBody(g1);
109 IntPtr b2 = d.GeomGetBody(g2);
110 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
111 return;
112
113 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
114 for (int i = 0; i < count; ++i)
115 {
116 contact.geom = contacts[i];
117 IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
118 d.JointAttach(joint, b1, b2);
119 }
120
121 }
122
123 public override PhysicsActor AddAvatar(PhysicsVector position)
124 {
125 PhysicsVector pos = new PhysicsVector();
126 pos.X = position.X;
127 pos.Y = position.Y;
128 pos.Z = position.Z + 20;
129 OdeCharacter newAv = new OdeCharacter(this, pos);
130 this._characters.Add(newAv);
131 return newAv;
132 }
133
134 public override void RemoveAvatar(PhysicsActor actor)
135 {
136
137 }
138
139 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
140 {
141 PhysicsVector pos = new PhysicsVector();
142 pos.X = position.X;
143 pos.Y = position.Y;
144 pos.Z = position.Z;
145 PhysicsVector siz = new PhysicsVector();
146 siz.X = size.X;
147 siz.Y = size.Y;
148 siz.Z = size.Z;
149 return new OdePrim();
150 }
151
152 public override void Simulate(float timeStep)
153 {
154 foreach (OdeCharacter actor in _characters)
155 {
156 actor.Move(timeStep * 5f);
157 }
158 d.SpaceCollide(space, IntPtr.Zero, nearCallback);
159 d.WorldQuickStep(world, timeStep * 5f);
160 d.JointGroupEmpty(contactgroup);
161 foreach (OdeCharacter actor in _characters)
162 {
163 actor.UpdatePosition();
164 }
165
166 }
167
168 public override void GetResults()
169 {
170
171 }
172
173 public override bool IsThreaded
174 {
175 get
176 {
177 return (false); // for now we won't be multithreaded
178 }
179 }
180
181 public override void SetTerrain(float[] heightMap)
182 {
183 for (int i = 0; i < 65536; i++)
184 {
185 this._heightmap[i] = (double)heightMap[i];
186 }
187 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
188 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
189 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
190 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
191 d.Matrix3 R = new d.Matrix3();
192
193 Axiom.MathLib.Quaternion q1 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(1,0,0));
194 Axiom.MathLib.Quaternion q2 =Axiom.MathLib.Quaternion.FromAngleAxis(1.5707f, new Axiom.MathLib.Vector3(0,1,0));
195 //Axiom.MathLib.Quaternion q3 = Axiom.MathLib.Quaternion.FromAngleAxis(3.14f, new Axiom.MathLib.Vector3(0, 0, 1));
196
197 q1 = q1 * q2;
198 //q1 = q1 * q3;
199 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3();
200 float angle = 0;
201 q1.ToAngleAxis(ref angle, ref v3);
202
203 d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
204 d.GeomSetRotation(LandGeom, ref R);
205 d.GeomSetPosition(LandGeom, 128, 128, 0);
206 }
207
208 public override void DeleteTerrain()
209 {
210
211 }
212 }
213
214 public class OdeCharacter : PhysicsActor
215 {
216 private PhysicsVector _position;
217 private PhysicsVector _velocity;
218 private PhysicsVector _acceleration;
219 private bool flying;
220 //private float gravityAccel;
221 private IntPtr BoundingCapsule;
222 IntPtr capsule_geom;
223 d.Mass capsule_mass;
224
225 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
226 {
227 _velocity = new PhysicsVector();
228 _position = pos;
229 _acceleration = new PhysicsVector();
230 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
231 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
232 this.BoundingCapsule = d.BodyCreate(OdeScene.world);
233 d.BodySetMass(BoundingCapsule, ref capsule_mass);
234 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
235 d.GeomSetBody(capsule_geom, BoundingCapsule);
236 }
237
238 public override bool Flying
239 {
240 get
241 {
242 return flying;
243 }
244 set
245 {
246 flying = value;
247 }
248 }
249
250 public override PhysicsVector Position
251 {
252 get
253 {
254 return _position;
255 }
256 set
257 {
258 _position = value;
259 }
260 }
261
262 public override PhysicsVector Velocity
263 {
264 get
265 {
266 return _velocity;
267 }
268 set
269 {
270 _velocity = value;
271 }
272 }
273
274 public override bool Kinematic
275 {
276 get
277 {
278 return false;
279 }
280 set
281 {
282
283 }
284 }
285
286 public override Axiom.MathLib.Quaternion Orientation
287 {
288 get
289 {
290 return Axiom.MathLib.Quaternion.Identity;
291 }
292 set
293 {
294
295 }
296 }
297
298 public override PhysicsVector Acceleration
299 {
300 get
301 {
302 return _acceleration;
303 }
304
305 }
306 public void SetAcceleration(PhysicsVector accel)
307 {
308 this._acceleration = accel;
309 }
310
311 public override void AddForce(PhysicsVector force)
312 {
313
314 }
315
316 public override void SetMomentum(PhysicsVector momentum)
317 {
318
319 }
320
321 public void Move(float timeStep)
322 {
323 PhysicsVector vec = new PhysicsVector();
324 vec.X = this._velocity.X * timeStep;
325 vec.Y = this._velocity.Y * timeStep;
326 if (flying)
327 {
328 vec.Z = (this._velocity.Z + 0.5f) * timeStep;
329 }
330 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
331 }
332
333 public void UpdatePosition()
334 {
335 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
336 this._position.X = vec.X;
337 this._position.Y = vec.Y;
338 this._position.Z = vec.Z;
339 }
340 }
341
342 public class OdePrim : PhysicsActor
343 {
344 private PhysicsVector _position;
345 private PhysicsVector _velocity;
346 private PhysicsVector _acceleration;
347
348 public OdePrim()
349 {
350 _velocity = new PhysicsVector();
351 _position = new PhysicsVector();
352 _acceleration = new PhysicsVector();
353 }
354 public override bool Flying
355 {
356 get
357 {
358 return false; //no flying prims for you
359 }
360 set
361 {
362
363 }
364 }
365 public override PhysicsVector Position
366 {
367 get
368 {
369 PhysicsVector pos = new PhysicsVector();
370 // PhysicsVector vec = this._prim.Position;
371 //pos.X = vec.X;
372 //pos.Y = vec.Y;
373 //pos.Z = vec.Z;
374 return pos;
375
376 }
377 set
378 {
379 /*PhysicsVector vec = value;
380 PhysicsVector pos = new PhysicsVector();
381 pos.X = vec.X;
382 pos.Y = vec.Y;
383 pos.Z = vec.Z;
384 this._prim.Position = pos;*/
385 }
386 }
387
388 public override PhysicsVector Velocity
389 {
390 get
391 {
392 return _velocity;
393 }
394 set
395 {
396 _velocity = value;
397 }
398 }
399
400 public override bool Kinematic
401 {
402 get
403 {
404 return false;
405 //return this._prim.Kinematic;
406 }
407 set
408 {
409 //this._prim.Kinematic = value;
410 }
411 }
412
413 public override Axiom.MathLib.Quaternion Orientation
414 {
415 get
416 {
417 Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
418 return res;
419 }
420 set
421 {
422
423 }
424 }
425
426 public override PhysicsVector Acceleration
427 {
428 get
429 {
430 return _acceleration;
431 }
432
433 }
434 public void SetAcceleration(PhysicsVector accel)
435 {
436 this._acceleration = accel;
437 }
438
439 public override void AddForce(PhysicsVector force)
440 {
441
442 }
443
444 public override void SetMomentum(PhysicsVector momentum)
445 {
446
447 }
448
449
450 }
451
452}
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj
new file mode 100644
index 0000000..8d57bd5
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj
@@ -0,0 +1,97 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{63A05FE9-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Physics.OdePlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Physics.OdePlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Axiom.MathLib.dll" >
66 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="Ode.NET.dll" >
70 <HintPath>..\..\..\bin\Ode.NET.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
76 <Name>OpenSim.Physics.Manager</Name>
77 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 </ItemGroup>
82 <ItemGroup>
83 <Compile Include="AssemblyInfo.cs">
84 <SubType>Code</SubType>
85 </Compile>
86 <Compile Include="OdePlugin.cs">
87 <SubType>Code</SubType>
88 </Compile>
89 </ItemGroup>
90 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
91 <PropertyGroup>
92 <PreBuildEvent>
93 </PreBuildEvent>
94 <PostBuildEvent>
95 </PostBuildEvent>
96 </PropertyGroup>
97</Project>
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build
new file mode 100644
index 0000000..a49782f
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/OdePlugin/OpenSim.Physics.OdePlugin.dll.build
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Physics.OdePlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Physics.OdePlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="OdePlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="../../../bin/Axiom.MathLib.dll" />
24 <include name="../../../bin/OpenSim.Physics.Manager.dll" />
25 <include name="../../../bin/Ode.NET.dll" />
26 </references>
27 </csc>
28 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/Physics/" />
29 <mkdir dir="${project::get-base-directory()}/../../../bin/Physics/"/>
30 <copy todir="${project::get-base-directory()}/../../../bin/Physics/">
31 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
32 <include name="*.dll"/>
33 <include name="*.exe"/>
34 </fileset>
35 </copy>
36 </target>
37 <target name="clean">
38 <delete dir="${bin.dir}" failonerror="false" />
39 <delete dir="${obj.dir}" failonerror="false" />
40 </target>
41 <target name="doc" description="Creates documentation.">
42 </target>
43</project>
diff --git a/OpenSim/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs
new file mode 100644
index 0000000..913aae7
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/PhysXPlugin/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("RealPhysXplugin")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("RealPhysXplugin")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj
new file mode 100644
index 0000000..b72bb0f
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj
@@ -0,0 +1,97 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{988F0AC4-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Physics.PhysXPlugin</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Physics.PhysXPlugin</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\Physics\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\Physics\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Axiom.MathLib.dll" >
66 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="PhysX_Wrapper_Dotnet.dll" >
70 <HintPath>..\..\..\bin\PhysX_Wrapper_Dotnet.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\Manager\OpenSim.Physics.Manager.csproj">
76 <Name>OpenSim.Physics.Manager</Name>
77 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 </ItemGroup>
82 <ItemGroup>
83 <Compile Include="AssemblyInfo.cs">
84 <SubType>Code</SubType>
85 </Compile>
86 <Compile Include="PhysXPlugin.cs">
87 <SubType>Code</SubType>
88 </Compile>
89 </ItemGroup>
90 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
91 <PropertyGroup>
92 <PreBuildEvent>
93 </PreBuildEvent>
94 <PostBuildEvent>
95 </PostBuildEvent>
96 </PropertyGroup>
97</Project>
diff --git a/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build
new file mode 100644
index 0000000..2ea5534
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/PhysXPlugin/OpenSim.Physics.PhysXPlugin.dll.build
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Physics.PhysXPlugin" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Physics.PhysXPlugin" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="PhysXPlugin.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="../../../bin/Axiom.MathLib.dll" />
24 <include name="../../../bin/PhysX_Wrapper_Dotnet.dll" />
25 <include name="../../../bin/OpenSim.Physics.Manager.dll" />
26 </references>
27 </csc>
28 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/Physics/" />
29 <mkdir dir="${project::get-base-directory()}/../../../bin/Physics/"/>
30 <copy todir="${project::get-base-directory()}/../../../bin/Physics/">
31 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
32 <include name="*.dll"/>
33 <include name="*.exe"/>
34 </fileset>
35 </copy>
36 </target>
37 <target name="clean">
38 <delete dir="${bin.dir}" failonerror="false" />
39 <delete dir="${obj.dir}" failonerror="false" />
40 </target>
41 <target name="doc" description="Creates documentation.">
42 </target>
43</project>
diff --git a/OpenSim/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs
new file mode 100644
index 0000000..dff1ee2
--- /dev/null
+++ b/OpenSim/OpenSim.Physics/PhysXPlugin/PhysXPlugin.cs
@@ -0,0 +1,449 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27/*
28* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
29*
30* Redistribution and use in source and binary forms, with or without
31* modification, are permitted provided that the following conditions are met:
32* * Redistributions of source code must retain the above copyright
33* notice, this list of conditions and the following disclaimer.
34* * Redistributions in binary form must reproduce the above copyright
35* notice, this list of conditions and the following disclaimer in the
36* documentation and/or other materials provided with the distribution.
37* * Neither the name of the <organization> nor the
38* names of its contributors may be used to endorse or promote products
39* derived from this software without specific prior written permission.
40*
41* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
42* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
45* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51*
52*/
53using System;
54using System.Collections.Generic;
55using OpenSim.Physics.Manager;
56using PhysXWrapper;
57
58namespace OpenSim.Physics.PhysXPlugin
59{
60 /// <summary>
61 /// Will be the PhysX plugin but for now will be a very basic physics engine
62 /// </summary>
63 public class PhysXPlugin : IPhysicsPlugin
64 {
65 private PhysXScene _mScene;
66
67 public PhysXPlugin()
68 {
69
70 }
71
72 public bool Init()
73 {
74 return true;
75 }
76
77 public PhysicsScene GetScene()
78 {
79 if(_mScene == null)
80 {
81 _mScene = new PhysXScene();
82 }
83 return(_mScene);
84 }
85
86 public string GetName()
87 {
88 return("RealPhysX");
89 }
90
91 public void Dispose()
92 {
93
94 }
95 }
96
97 public class PhysXScene :PhysicsScene
98 {
99 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
100 private List<PhysXPrim> _prims = new List<PhysXPrim>();
101 private float[] _heightMap = null;
102 private NxPhysicsSDK mySdk;
103 private NxScene scene;
104
105 public PhysXScene()
106 {
107 mySdk = NxPhysicsSDK.CreateSDK();
108 Console.WriteLine("Sdk created - now creating scene");
109 scene = mySdk.CreateScene();
110
111 }
112
113 public override PhysicsActor AddAvatar(PhysicsVector position)
114 {
115 Vec3 pos = new Vec3();
116 pos.X = position.X;
117 pos.Y = position.Y;
118 pos.Z = position.Z;
119 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
120 act.Position = position;
121 _characters.Add(act);
122 return act;
123 }
124
125 public override void RemoveAvatar(PhysicsActor actor)
126 {
127
128 }
129
130 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
131 {
132 Vec3 pos = new Vec3();
133 pos.X = position.X;
134 pos.Y = position.Y;
135 pos.Z = position.Z;
136 Vec3 siz = new Vec3();
137 siz.X = size.X;
138 siz.Y = size.Y;
139 siz.Z = size.Z;
140 PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
141 _prims.Add(act);
142 return act;
143 }
144 public override void Simulate(float timeStep)
145 {
146 try
147 {
148 foreach (PhysXCharacter actor in _characters)
149 {
150 actor.Move(timeStep);
151 }
152 scene.Simulate(timeStep);
153 scene.FetchResults();
154 scene.UpdateControllers();
155
156 foreach (PhysXCharacter actor in _characters)
157 {
158 actor.UpdatePosition();
159 }
160 }
161 catch (Exception e)
162 {
163 Console.WriteLine(e.Message);
164 }
165
166 }
167
168 public override void GetResults()
169 {
170
171 }
172
173 public override bool IsThreaded
174 {
175 get
176 {
177 return(false); // for now we won't be multithreaded
178 }
179 }
180
181 public override void SetTerrain(float[] heightMap)
182 {
183 if (this._heightMap != null)
184 {
185 Console.WriteLine("PhysX - deleting old terrain");
186 this.scene.DeleteTerrain();
187 }
188 this._heightMap = heightMap;
189 this.scene.AddTerrain(heightMap);
190 }
191
192 public override void DeleteTerrain()
193 {
194 this.scene.DeleteTerrain();
195 }
196 }
197
198 public class PhysXCharacter : PhysicsActor
199 {
200 private PhysicsVector _position;
201 private PhysicsVector _velocity;
202 private PhysicsVector _acceleration;
203 private NxCharacter _character;
204 private bool flying;
205 private float gravityAccel;
206
207 public PhysXCharacter(NxCharacter character)
208 {
209 _velocity = new PhysicsVector();
210 _position = new PhysicsVector();
211 _acceleration = new PhysicsVector();
212 _character = character;
213 }
214
215 public override bool Flying
216 {
217 get
218 {
219 return flying;
220 }
221 set
222 {
223 flying = value;
224 }
225 }
226
227 public override PhysicsVector Position
228 {
229 get
230 {
231 return _position;
232 }
233 set
234 {
235 _position = value;
236 Vec3 ps = new Vec3();
237 ps.X = value.X;
238 ps.Y = value.Y;
239 ps.Z = value.Z;
240 this._character.Position = ps;
241 }
242 }
243
244 public override PhysicsVector Velocity
245 {
246 get
247 {
248 return _velocity;
249 }
250 set
251 {
252 _velocity = value;
253 }
254 }
255
256 public override bool Kinematic
257 {
258 get
259 {
260 return false;
261 }
262 set
263 {
264
265 }
266 }
267
268 public override Axiom.MathLib.Quaternion Orientation
269 {
270 get
271 {
272 return Axiom.MathLib.Quaternion.Identity;
273 }
274 set
275 {
276
277 }
278 }
279
280 public override PhysicsVector Acceleration
281 {
282 get
283 {
284 return _acceleration;
285 }
286
287 }
288 public void SetAcceleration (PhysicsVector accel)
289 {
290 this._acceleration = accel;
291 }
292
293 public override void AddForce(PhysicsVector force)
294 {
295
296 }
297
298 public override void SetMomentum(PhysicsVector momentum)
299 {
300
301 }
302
303 public void Move(float timeStep)
304 {
305 Vec3 vec = new Vec3();
306 vec.X = this._velocity.X * timeStep;
307 vec.Y = this._velocity.Y * timeStep;
308 if(flying)
309 {
310 vec.Z = ( this._velocity.Z) * timeStep;
311 }
312 else
313 {
314 gravityAccel+= -9.8f;
315 vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
316 }
317 int res = this._character.Move(vec);
318 if(res == 1)
319 {
320 gravityAccel = 0;
321 }
322 }
323
324 public void UpdatePosition()
325 {
326 Vec3 vec = this._character.Position;
327 this._position.X = vec.X;
328 this._position.Y = vec.Y;
329 this._position.Z = vec.Z;
330 }
331 }
332
333 public class PhysXPrim : PhysicsActor
334 {
335 private PhysicsVector _position;
336 private PhysicsVector _velocity;
337 private PhysicsVector _acceleration;
338 private NxActor _prim;
339
340 public PhysXPrim(NxActor prim)
341 {
342 _velocity = new PhysicsVector();
343 _position = new PhysicsVector();
344 _acceleration = new PhysicsVector();
345 _prim = prim;
346 }
347 public override bool Flying
348 {
349 get
350 {
351 return false; //no flying prims for you
352 }
353 set
354 {
355
356 }
357 }
358 public override PhysicsVector Position
359 {
360 get
361 {
362 PhysicsVector pos = new PhysicsVector();
363 Vec3 vec = this._prim.Position;
364 pos.X = vec.X;
365 pos.Y = vec.Y;
366 pos.Z = vec.Z;
367 return pos;
368
369 }
370 set
371 {
372 PhysicsVector vec = value;
373 Vec3 pos = new Vec3();
374 pos.X = vec.X;
375 pos.Y = vec.Y;
376 pos.Z = vec.Z;
377 this._prim.Position = pos;
378 }
379 }
380
381 public override PhysicsVector Velocity
382 {
383 get
384 {
385 return _velocity;
386 }
387 set
388 {
389 _velocity = value;
390 }
391 }
392
393 public override bool Kinematic
394 {
395 get
396 {
397 return this._prim.Kinematic;
398 }
399 set
400 {
401 this._prim.Kinematic = value;
402 }
403 }
404
405 public override Axiom.MathLib.Quaternion Orientation
406 {
407 get
408 {
409 Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
410 PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
411 res.w = quat.W;
412 res.x = quat.X;
413 res.y = quat.Y;
414 res.z = quat.Z;
415 return res;
416 }
417 set
418 {
419
420 }
421 }
422
423 public override PhysicsVector Acceleration
424 {
425 get
426 {
427 return _acceleration;
428 }
429
430 }
431 public void SetAcceleration (PhysicsVector accel)
432 {
433 this._acceleration = accel;
434 }
435
436 public override void AddForce(PhysicsVector force)
437 {
438
439 }
440
441 public override void SetMomentum(PhysicsVector momentum)
442 {
443
444 }
445
446
447 }
448
449}
diff --git a/OpenSim/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim/OpenSim.RegionServer/AgentAssetUpload.cs
new file mode 100644
index 0000000..dd2b2a9
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/AgentAssetUpload.cs
@@ -0,0 +1,232 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Assets;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.Utilities;
7using libsecondlife;
8using libsecondlife.Packets;
9
10namespace OpenSim
11{
12 public class AgentAssetUpload
13 {
14 private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
15 private ClientView ourClient;
16 private AssetCache m_assetCache;
17 private InventoryCache m_inventoryCache;
18
19 public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
20 {
21 this.ourClient = client;
22 m_assetCache = assetCache;
23 m_inventoryCache = inventoryCache;
24 }
25
26 public void AddUpload(LLUUID transactionID, AssetBase asset)
27 {
28 AssetTransaction upload = new AssetTransaction();
29 lock (this.transactions)
30 {
31 upload.Asset = asset;
32 upload.TransactionID = transactionID;
33 this.transactions.Add(transactionID, upload);
34 }
35 if (upload.Asset.Data.Length > 2)
36 {
37 //is complete
38 upload.UploadComplete = true;
39 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
40 response.AssetBlock.Type = asset.Type;
41 response.AssetBlock.Success = true;
42 response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
43 this.ourClient.OutPacket(response);
44 m_assetCache.AddAsset(asset);
45 }
46 else
47 {
48 upload.UploadComplete = false;
49 upload.XferID = Util.GetNextXferID();
50 RequestXferPacket xfer = new RequestXferPacket();
51 xfer.XferID.ID = upload.XferID;
52 xfer.XferID.VFileType = upload.Asset.Type;
53 xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
54 xfer.XferID.FilePath = 0;
55 xfer.XferID.Filename = new byte[0];
56 this.ourClient.OutPacket(xfer);
57 }
58
59 }
60
61 public AssetBase GetUpload(LLUUID transactionID)
62 {
63 if (this.transactions.ContainsKey(transactionID))
64 {
65 return this.transactions[transactionID].Asset;
66 }
67
68 return null;
69 }
70
71 public void HandleUploadPacket(AssetUploadRequestPacket pack, LLUUID assetID)
72 {
73 // Console.Write("asset upload request , type = " + pack.AssetBlock.Type.ToString());
74 AssetBase asset = null;
75 if (pack.AssetBlock.Type == 0)
76 {
77
78 //first packet for transaction
79 asset = new AssetBase();
80 asset.FullID = assetID;
81 asset.Type = pack.AssetBlock.Type;
82 asset.InvType = asset.Type;
83 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
84 asset.Data = pack.AssetBlock.AssetData;
85
86
87 }
88 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5 | pack.AssetBlock.Type == 7)
89 {
90
91 asset = new AssetBase();
92 asset.FullID = assetID;
93 // Console.WriteLine("skin asset id is " + assetID.ToStringHyphenated());
94 asset.Type = pack.AssetBlock.Type;
95 asset.InvType = asset.Type;
96 asset.Name = "NewClothing" + Util.RandomClass.Next(1, 1000).ToString("000");
97 asset.Data = pack.AssetBlock.AssetData;
98
99
100 }
101
102 if (asset != null)
103 {
104 this.AddUpload(pack.AssetBlock.TransactionID, asset);
105 }
106 else
107 {
108
109 //currently we don't support this asset type
110 //so lets just tell the client that the upload is complete
111 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
112 response.AssetBlock.Type = pack.AssetBlock.Type;
113 response.AssetBlock.Success = true;
114 response.AssetBlock.UUID = pack.AssetBlock.TransactionID.Combine(this.ourClient.SecureSessionID);
115 this.ourClient.OutPacket(response);
116 }
117
118 }
119
120 #region Xfer packet system for larger uploads
121
122 public void HandleXferPacket(SendXferPacketPacket xferPacket)
123 {
124 lock (this.transactions)
125 {
126 foreach (AssetTransaction trans in this.transactions.Values)
127 {
128 if (trans.XferID == xferPacket.XferID.ID)
129 {
130 if (trans.Asset.Data.Length > 1)
131 {
132 byte[] newArray = new byte[trans.Asset.Data.Length + xferPacket.DataPacket.Data.Length];
133 Array.Copy(trans.Asset.Data, 0, newArray, 0, trans.Asset.Data.Length);
134 Array.Copy(xferPacket.DataPacket.Data, 0, newArray, trans.Asset.Data.Length, xferPacket.DataPacket.Data.Length);
135 trans.Asset.Data = newArray;
136 }
137 else
138 {
139 byte[] newArray = new byte[xferPacket.DataPacket.Data.Length - 4];
140 Array.Copy(xferPacket.DataPacket.Data, 4, newArray, 0, xferPacket.DataPacket.Data.Length - 4);
141 trans.Asset.Data = newArray;
142 }
143
144 if ((xferPacket.XferID.Packet & 2147483648) != 0)
145 {
146 //end of transfer
147 trans.UploadComplete = true;
148 AssetUploadCompletePacket response = new AssetUploadCompletePacket();
149 response.AssetBlock.Type = trans.Asset.Type;
150 response.AssetBlock.Success = true;
151 response.AssetBlock.UUID = trans.TransactionID.Combine(this.ourClient.SecureSessionID);
152 this.ourClient.OutPacket(response);
153
154 m_assetCache.AddAsset(trans.Asset);
155 //check if we should add it to inventory
156 if (trans.AddToInventory)
157 {
158 // m_assetCache.AddAsset(trans.Asset);
159 m_inventoryCache.AddNewInventoryItem(this.ourClient, trans.InventFolder, trans.Asset);
160 }
161
162
163 }
164 break;
165 }
166
167 }
168 }
169
170 ConfirmXferPacketPacket confirmXfer = new ConfirmXferPacketPacket();
171 confirmXfer.XferID.ID = xferPacket.XferID.ID;
172 confirmXfer.XferID.Packet = xferPacket.XferID.Packet;
173 this.ourClient.OutPacket(confirmXfer);
174 }
175
176 #endregion
177
178 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
179 {
180 AssetBase asset = null;
181 if (this.transactions.ContainsKey(transactionID))
182 {
183 AssetTransaction trans = this.transactions[transactionID];
184 if (trans.UploadComplete)
185 {
186 m_assetCache.AddAsset(trans.Asset);
187 asset = trans.Asset;
188 }
189 }
190
191 return asset;
192 }
193
194 public void CreateInventoryItem(CreateInventoryItemPacket packet)
195 {
196 if (this.transactions.ContainsKey(packet.InventoryBlock.TransactionID))
197 {
198 AssetTransaction trans = this.transactions[packet.InventoryBlock.TransactionID];
199 trans.Asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
200 trans.Asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
201 trans.Asset.Type = packet.InventoryBlock.Type;
202 trans.Asset.InvType = packet.InventoryBlock.InvType;
203 if (trans.UploadComplete)
204 {
205 //already complete so we can add it to the inventory
206 //m_assetCache.AddAsset(trans.Asset);
207 m_inventoryCache.AddNewInventoryItem(this.ourClient, packet.InventoryBlock.FolderID, trans.Asset);
208 }
209 else
210 {
211 trans.AddToInventory = true;
212 trans.InventFolder = packet.InventoryBlock.FolderID;
213 }
214 }
215 }
216
217 private class AssetTransaction
218 {
219 public uint XferID;
220 public AssetBase Asset;
221 public bool AddToInventory;
222 public LLUUID InventFolder = LLUUID.Zero;
223 public bool UploadComplete = false;
224 public LLUUID TransactionID = LLUUID.Zero;
225
226 public AssetTransaction()
227 {
228
229 }
230 }
231 }
232}
diff --git a/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs b/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs
new file mode 100644
index 0000000..ccebb24
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs
@@ -0,0 +1,574 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Threading;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities;
37
38namespace OpenSim.Assets
39{
40 /// <summary>
41 /// Manages local cache of assets and their sending to viewers.
42 /// </summary>
43 public class AssetCache : IAssetReceiver
44 {
45 public Dictionary<libsecondlife.LLUUID, AssetInfo> Assets;
46 public Dictionary<libsecondlife.LLUUID, TextureImage> Textures;
47
48 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
49 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
50
51 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
52 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
53
54 private IAssetServer _assetServer;
55 private Thread _assetCacheThread;
56 private LLUUID[] textureList = new LLUUID[5];
57
58 /// <summary>
59 ///
60 /// </summary>
61 public AssetCache(IAssetServer assetServer)
62 {
63 Console.WriteLine("Creating Asset cache");
64 _assetServer = assetServer;
65 _assetServer.SetReceiver(this);
66 Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>();
67 Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>();
68 this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
69 this._assetCacheThread.IsBackground = true;
70 this._assetCacheThread.Start();
71
72 }
73
74 /// <summary>
75 ///
76 /// </summary>
77 public void RunAssetManager()
78 {
79 while (true)
80 {
81 try
82 {
83 //Console.WriteLine("Asset cache loop");
84 this.ProcessAssetQueue();
85 this.ProcessTextureQueue();
86 Thread.Sleep(500);
87 }
88 catch (Exception e)
89 {
90 Console.WriteLine(e.Message);
91 }
92 }
93 }
94
95 public void LoadDefaultTextureSet()
96 {
97 //hack: so we can give each user a set of textures
98 textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001");
99 textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002");
100 textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003");
101 textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004");
102 textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005");
103
104 for (int i = 0; i < textureList.Length; i++)
105 {
106 this._assetServer.RequestAsset(textureList[i], true);
107 }
108
109 }
110
111 public AssetBase[] CreateNewInventorySet(LLUUID agentID)
112 {
113 AssetBase[] inventorySet = new AssetBase[this.textureList.Length];
114 for (int i = 0; i < textureList.Length; i++)
115 {
116 if (this.Textures.ContainsKey(textureList[i]))
117 {
118 inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]);
119 TextureImage image = new TextureImage(inventorySet[i]);
120 this.Textures.Add(image.FullID, image);
121 this._assetServer.UploadNewAsset(image); //save the asset to the asset server
122 }
123 }
124 return inventorySet;
125 }
126
127 public AssetBase GetAsset(LLUUID assetID)
128 {
129 AssetBase asset = null;
130 if(this.Textures.ContainsKey(assetID))
131 {
132 asset = this.Textures[assetID];
133 }
134 else if (this.Assets.ContainsKey(assetID))
135 {
136 asset = this.Assets[assetID];
137 }
138 return asset;
139 }
140
141 public void AddAsset(AssetBase asset)
142 {
143 if (asset.Type == 0)
144 {
145 if (!this.Textures.ContainsKey(asset.FullID))
146 { //texture
147 TextureImage textur = new TextureImage(asset);
148 this.Textures.Add(textur.FullID, textur);
149 this._assetServer.UploadNewAsset(asset);
150 }
151 }
152 else
153 {
154 if (!this.Assets.ContainsKey(asset.FullID))
155 {
156 AssetInfo assetInf = new AssetInfo(asset);
157 this.Assets.Add(assetInf.FullID, assetInf);
158 this._assetServer.UploadNewAsset(asset);
159 }
160 }
161 }
162
163 /// <summary>
164 ///
165 /// </summary>
166 private void ProcessTextureQueue()
167 {
168 if (this.TextureRequests.Count == 0)
169 {
170 //no requests waiting
171 return;
172 }
173 int num;
174
175 if (this.TextureRequests.Count < 5)
176 {
177 //lower than 5 so do all of them
178 num = this.TextureRequests.Count;
179 }
180 else
181 {
182 num = 5;
183 }
184 AssetRequest req;
185 for (int i = 0; i < num; i++)
186 {
187 req = (AssetRequest)this.TextureRequests[i];
188 if (req.PacketCounter != req.NumPackets)
189 {
190 // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005"))
191 if (req.PacketCounter == 0)
192 {
193 //first time for this request so send imagedata packet
194 if (req.NumPackets == 1)
195 {
196 //only one packet so send whole file
197 ImageDataPacket im = new ImageDataPacket();
198 im.ImageID.Packets = 1;
199 im.ImageID.ID = req.ImageInfo.FullID;
200 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
201 im.ImageData.Data = req.ImageInfo.Data;
202 im.ImageID.Codec = 2;
203 req.RequestUser.OutPacket(im);
204 req.PacketCounter++;
205 //req.ImageInfo.l= time;
206 //System.Console.WriteLine("sent texture: "+req.image_info.FullID);
207 }
208 else
209 {
210 //more than one packet so split file up
211 ImageDataPacket im = new ImageDataPacket();
212 im.ImageID.Packets = (ushort)req.NumPackets;
213 im.ImageID.ID = req.ImageInfo.FullID;
214 im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
215 im.ImageData.Data = new byte[600];
216 Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
217 im.ImageID.Codec = 2;
218 req.RequestUser.OutPacket(im);
219 req.PacketCounter++;
220 //req.ImageInfo.last_used = time;
221 //System.Console.WriteLine("sent first packet of texture:
222 }
223 }
224 else
225 {
226 //send imagepacket
227 //more than one packet so split file up
228 ImagePacketPacket im = new ImagePacketPacket();
229 im.ImageID.Packet = (ushort)req.PacketCounter;
230 im.ImageID.ID = req.ImageInfo.FullID;
231 int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1);
232 if (size > 1000) size = 1000;
233 im.ImageData.Data = new byte[size];
234 Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size);
235 req.RequestUser.OutPacket(im);
236 req.PacketCounter++;
237 //req.ImageInfo.last_used = time;
238 //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
239 }
240 }
241 }
242
243 //remove requests that have been completed
244 int count = 0;
245 for (int i = 0; i < num; i++)
246 {
247 if (this.TextureRequests.Count > count)
248 {
249 req = (AssetRequest)this.TextureRequests[count];
250 if (req.PacketCounter == req.NumPackets)
251 {
252 this.TextureRequests.Remove(req);
253 }
254 else
255 {
256 count++;
257 }
258 }
259 }
260
261 }
262 public void AssetReceived(AssetBase asset, bool IsTexture)
263 {
264 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
265 {
266 //check if it is a texture or not
267 //then add to the correct cache list
268 //then check for waiting requests for this asset/texture (in the Requested lists)
269 //and move those requests into the Requests list.
270 if (IsTexture)
271 {
272 TextureImage image = new TextureImage(asset);
273 this.Textures.Add(image.FullID, image);
274 if (this.RequestedTextures.ContainsKey(image.FullID))
275 {
276 AssetRequest req = this.RequestedTextures[image.FullID];
277 req.ImageInfo = image;
278 if (image.Data.LongLength > 600)
279 {
280 //over 600 bytes so split up file
281 req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000;
282 }
283 else
284 {
285 req.NumPackets = 1;
286 }
287 this.RequestedTextures.Remove(image.FullID);
288 this.TextureRequests.Add(req);
289 }
290 }
291 else
292 {
293 AssetInfo assetInf = new AssetInfo(asset);
294 this.Assets.Add(assetInf.FullID, assetInf);
295 if (this.RequestedAssets.ContainsKey(assetInf.FullID))
296 {
297 AssetRequest req = this.RequestedAssets[assetInf.FullID];
298 req.AssetInf = assetInf;
299 if (assetInf.Data.LongLength > 600)
300 {
301 //over 600 bytes so split up file
302 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
303 }
304 else
305 {
306 req.NumPackets = 1;
307 }
308 this.RequestedAssets.Remove(assetInf.FullID);
309 this.AssetRequests.Add(req);
310 }
311 }
312 }
313 }
314
315 public void AssetNotFound(AssetBase asset)
316 {
317 //the asset server had no knowledge of requested asset
318
319 }
320
321 #region Assets
322 /// <summary>
323 ///
324 /// </summary>
325 /// <param name="userInfo"></param>
326 /// <param name="transferRequest"></param>
327 public void AddAssetRequest(ClientView userInfo, TransferRequestPacket transferRequest)
328 {
329 LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
330 //check to see if asset is in local cache, if not we need to request it from asset server.
331 if (!this.Assets.ContainsKey(requestID))
332 {
333 //not found asset
334 // so request from asset server
335 if (!this.RequestedAssets.ContainsKey(requestID))
336 {
337 AssetRequest request = new AssetRequest();
338 request.RequestUser = userInfo;
339 request.RequestAssetID = requestID;
340 request.TransferRequestID = transferRequest.TransferInfo.TransferID;
341 this.RequestedAssets.Add(requestID, request);
342 this._assetServer.RequestAsset(requestID, false);
343 }
344 return;
345 }
346 //it is in our cache
347 AssetInfo asset = this.Assets[requestID];
348
349 //work out how many packets it should be sent in
350 // and add to the AssetRequests list
351 AssetRequest req = new AssetRequest();
352 req.RequestUser = userInfo;
353 req.RequestAssetID = requestID;
354 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
355 req.AssetInf = asset;
356
357 if (asset.Data.LongLength > 600)
358 {
359 //over 600 bytes so split up file
360 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
361 }
362 else
363 {
364 req.NumPackets = 1;
365 }
366
367 this.AssetRequests.Add(req);
368 }
369
370 /// <summary>
371 ///
372 /// </summary>
373 private void ProcessAssetQueue()
374 {
375 if (this.AssetRequests.Count == 0)
376 {
377 //no requests waiting
378 return;
379 }
380 int num;
381
382 if (this.AssetRequests.Count < 5)
383 {
384 //lower than 5 so do all of them
385 num = this.AssetRequests.Count;
386 }
387 else
388 {
389 num = 5;
390 }
391 AssetRequest req;
392 for (int i = 0; i < num; i++)
393 {
394 req = (AssetRequest)this.AssetRequests[i];
395
396 TransferInfoPacket Transfer = new TransferInfoPacket();
397 Transfer.TransferInfo.ChannelType = 2;
398 Transfer.TransferInfo.Status = 0;
399 Transfer.TransferInfo.TargetType = 0;
400 Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes();
401 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
402 Transfer.TransferInfo.TransferID = req.TransferRequestID;
403 req.RequestUser.OutPacket(Transfer);
404
405 if (req.NumPackets == 1)
406 {
407 TransferPacketPacket TransferPacket = new TransferPacketPacket();
408 TransferPacket.TransferData.Packet = 0;
409 TransferPacket.TransferData.ChannelType = 2;
410 TransferPacket.TransferData.TransferID = req.TransferRequestID;
411 TransferPacket.TransferData.Data = req.AssetInf.Data;
412 TransferPacket.TransferData.Status = 1;
413 req.RequestUser.OutPacket(TransferPacket);
414 }
415 else
416 {
417 //more than one packet so split file up , for now it can't be bigger than 2000 bytes
418 TransferPacketPacket TransferPacket = new TransferPacketPacket();
419 TransferPacket.TransferData.Packet = 0;
420 TransferPacket.TransferData.ChannelType = 2;
421 TransferPacket.TransferData.TransferID = req.TransferRequestID;
422 byte[] chunk = new byte[1000];
423 Array.Copy(req.AssetInf.Data, chunk, 1000);
424 TransferPacket.TransferData.Data = chunk;
425 TransferPacket.TransferData.Status = 0;
426 req.RequestUser.OutPacket(TransferPacket);
427
428 TransferPacket = new TransferPacketPacket();
429 TransferPacket.TransferData.Packet = 1;
430 TransferPacket.TransferData.ChannelType = 2;
431 TransferPacket.TransferData.TransferID = req.TransferRequestID;
432 byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
433 Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
434 TransferPacket.TransferData.Data = chunk1;
435 TransferPacket.TransferData.Status = 1;
436 req.RequestUser.OutPacket(TransferPacket);
437 }
438
439 }
440
441 //remove requests that have been completed
442 for (int i = 0; i < num; i++)
443 {
444 this.AssetRequests.RemoveAt(0);
445 }
446
447 }
448
449 public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset)
450 {
451 AssetInfo newAsset = new AssetInfo();
452 newAsset.Data = new byte[sourceAsset.Data.Length];
453 Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length);
454 newAsset.FullID = LLUUID.Random();
455 newAsset.Type = sourceAsset.Type;
456 newAsset.InvType = sourceAsset.InvType;
457 return (newAsset);
458 }
459 #endregion
460
461 #region Textures
462 /// <summary>
463 ///
464 /// </summary>
465 /// <param name="userInfo"></param>
466 /// <param name="imageID"></param>
467 public void AddTextureRequest(ClientView userInfo, LLUUID imageID)
468 {
469 //check to see if texture is in local cache, if not request from asset server
470 if (!this.Textures.ContainsKey(imageID))
471 {
472 if (!this.RequestedTextures.ContainsKey(imageID))
473 {
474 //not is cache so request from asset server
475 AssetRequest request = new AssetRequest();
476 request.RequestUser = userInfo;
477 request.RequestAssetID = imageID;
478 request.IsTextureRequest = true;
479 this.RequestedTextures.Add(imageID, request);
480 this._assetServer.RequestAsset(imageID, true);
481 }
482 return;
483 }
484
485 TextureImage imag = this.Textures[imageID];
486 AssetRequest req = new AssetRequest();
487 req.RequestUser = userInfo;
488 req.RequestAssetID = imageID;
489 req.IsTextureRequest = true;
490 req.ImageInfo = imag;
491
492 if (imag.Data.LongLength > 600)
493 {
494 //over 600 bytes so split up file
495 req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000;
496 }
497 else
498 {
499 req.NumPackets = 1;
500 }
501 this.TextureRequests.Add(req);
502 }
503
504 public TextureImage CloneImage(LLUUID newOwner, TextureImage source)
505 {
506 TextureImage newImage = new TextureImage();
507 newImage.Data = new byte[source.Data.Length];
508 Array.Copy(source.Data, newImage.Data, source.Data.Length);
509 //newImage.filename = source.filename;
510 newImage.FullID = LLUUID.Random();
511 newImage.Name = source.Name;
512 return (newImage);
513 }
514 #endregion
515
516 }
517
518 public class AssetRequest
519 {
520 public ClientView RequestUser;
521 public LLUUID RequestAssetID;
522 public AssetInfo AssetInf;
523 public TextureImage ImageInfo;
524 public LLUUID TransferRequestID;
525 public long DataPointer = 0;
526 public int NumPackets = 0;
527 public int PacketCounter = 0;
528 public bool IsTextureRequest;
529 //public bool AssetInCache;
530 //public int TimeRequested;
531
532 public AssetRequest()
533 {
534
535 }
536 }
537
538 public class AssetInfo : AssetBase
539 {
540 public AssetInfo()
541 {
542
543 }
544
545 public AssetInfo(AssetBase aBase)
546 {
547 Data = aBase.Data;
548 FullID = aBase.FullID;
549 Type = aBase.Type;
550 InvType = aBase.InvType;
551 Name = aBase.Name;
552 Description = aBase.Description;
553 }
554 }
555
556 public class TextureImage : AssetBase
557 {
558 public TextureImage()
559 {
560
561 }
562
563 public TextureImage(AssetBase aBase)
564 {
565 Data = aBase.Data;
566 FullID = aBase.FullID;
567 Type = aBase.Type;
568 InvType = aBase.InvType;
569 Name = aBase.Name;
570 Description = aBase.Description;
571 }
572 }
573
574}
diff --git a/OpenSim/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim/OpenSim.RegionServer/Assets/InventoryCache.cs
new file mode 100644
index 0000000..64a7a32
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/Assets/InventoryCache.cs
@@ -0,0 +1,336 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using libsecondlife;
31using OpenSim;
32using libsecondlife.Packets;
33//using OpenSim.GridServers;
34using OpenSim.Framework.Inventory;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Interfaces;
37
38namespace OpenSim.Assets
39{
40 /// <summary>
41 /// Description of InventoryManager.
42 /// </summary>
43 public class InventoryCache
44 {
45 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
46 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
47 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
48 private const uint FULL_MASK_PERMISSIONS = 2147483647;
49
50 public InventoryCache()
51 {
52 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
53 _serverRequests = new List<UserServerRequest>();
54 }
55
56 public void AddNewAgentsInventory(AgentInventory agentInventory)
57 {
58 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID))
59 {
60 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
61 }
62 }
63
64 public AgentInventory FetchAgentsInventory(LLUUID agentID, IUserServer userserver)
65 {
66 AgentInventory res = null;
67 if (!this._agentsInventory.ContainsKey(agentID))
68 {
69 res = userserver.RequestAgentsInventory(agentID);
70 this._agentsInventory.Add(agentID,res);
71 }
72 return res;
73 }
74
75 public AgentInventory GetAgentsInventory(LLUUID agentID)
76 {
77 if (this._agentsInventory.ContainsKey(agentID))
78 {
79 return this._agentsInventory[agentID];
80 }
81
82 return null;
83 }
84
85 public void ClientLeaving(LLUUID clientID, IUserServer userserver)
86 {
87 if (this._agentsInventory.ContainsKey(clientID))
88 {
89 if (userserver != null)
90 {
91 userserver.UpdateAgentsInventory(clientID, this._agentsInventory[clientID]);
92 }
93 this._agentsInventory.Remove(clientID);
94 }
95 }
96
97 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
98 {
99 return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
100 }
101
102 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
103 {
104 bool res = false;
105 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
106 {
107 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
108 {
109 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type);
110 }
111 }
112 return res;
113 }
114
115 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
116 {
117 bool res = false;
118 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
119 {
120 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
121 {
122 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent);
123 }
124 }
125 return res;
126 }
127
128 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset)
129 {
130 LLUUID newItem = null;
131 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
132 {
133 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
134 if (newItem != null)
135 {
136 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem];
137 this.SendItemUpdateCreate(remoteClient, Item);
138 }
139 }
140
141 return newItem;
142 }
143 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
144 {
145 bool res = false;
146 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
147 {
148 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID);
149 if (res)
150 {
151 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
152 remove.AgentData.AgentID = remoteClient.AgentID;
153 remove.AgentData.SessionID = remoteClient.SessionID;
154 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
155 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
156 remove.InventoryData[0].ItemID = itemID;
157 remoteClient.OutPacket(remove);
158 }
159 }
160
161 return res;
162 }
163
164 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset)
165 {
166 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
167 {
168 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
169 if (res)
170 {
171 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
172 this.SendItemUpdateCreate(remoteClient, Item);
173 }
174 return res;
175 }
176
177 return false;
178 }
179
180 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
181 {
182 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
183 {
184 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
185 if (res)
186 {
187 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
188 this.SendItemUpdateCreate(remoteClient, Item);
189 }
190 return res;
191 }
192
193 return false;
194 }
195
196 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
197 {
198 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
199 {
200 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
201 if (FetchDescend.InventoryData.FetchItems)
202 {
203 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
204 {
205 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
206 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
207 Descend.AgentData.AgentID = userInfo.AgentID;
208 Descend.AgentData.OwnerID = Folder.OwnerID;
209 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
210 Descend.AgentData.Descendents = Folder.Items.Count;
211 Descend.AgentData.Version = Folder.Items.Count;
212
213
214 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
215 for (int i = 0; i < Folder.Items.Count; i++)
216 {
217
218 InventoryItem Item = Folder.Items[i];
219 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
220 Descend.ItemData[i].ItemID = Item.ItemID;
221 Descend.ItemData[i].AssetID = Item.AssetID;
222 Descend.ItemData[i].CreatorID = Item.CreatorID;
223 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
224 Descend.ItemData[i].CreationDate = 1000;
225 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
226 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
227 Descend.ItemData[i].Flags = 1;
228 Descend.ItemData[i].FolderID = Item.FolderID;
229 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
230 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
231 Descend.ItemData[i].InvType = Item.InvType;
232 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
233 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
234 Descend.ItemData[i].OwnerID = Item.OwnerID;
235 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
236 Descend.ItemData[i].SalePrice = 100;
237 Descend.ItemData[i].SaleType = 0;
238 Descend.ItemData[i].Type = Item.Type;
239 Descend.ItemData[i].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
240 }
241
242 userInfo.OutPacket(Descend);
243
244 }
245 }
246 else
247 {
248 Console.WriteLine("fetch subfolders");
249 }
250 }
251 }
252
253 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
254 {
255 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
256 {
257 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
258
259 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
260 {
261 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
262 {
263 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
264 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
265 InventoryReply.AgentData.AgentID = userInfo.AgentID;
266 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
267 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
268 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
269 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
270 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
271 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
272 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
273 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
274 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
275 InventoryReply.InventoryData[0].Flags = 0;
276 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
277 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
278 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
279 InventoryReply.InventoryData[0].InvType = Item.InvType;
280 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
281 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
282 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
283 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
284 InventoryReply.InventoryData[0].SalePrice = 100;
285 InventoryReply.InventoryData[0].SaleType = 0;
286 InventoryReply.InventoryData[0].Type = Item.Type;
287 InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
288 userInfo.OutPacket(InventoryReply);
289 }
290 }
291 }
292 }
293
294 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
295 {
296
297 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
298 InventoryReply.AgentData.AgentID = remoteClient.AgentID;
299 InventoryReply.AgentData.SimApproved = true;
300 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
301 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
302 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
303 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
304 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
305 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
306 InventoryReply.InventoryData[0].CreationDate = 1000;
307 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
308 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
309 InventoryReply.InventoryData[0].Flags = 0;
310 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
311 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
312 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
313 InventoryReply.InventoryData[0].InvType = Item.InvType;
314 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
315 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
316 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
317 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
318 InventoryReply.InventoryData[0].SalePrice = 100;
319 InventoryReply.InventoryData[0].SaleType = 0;
320 InventoryReply.InventoryData[0].Type = Item.Type;
321 InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
322
323 remoteClient.OutPacket(InventoryReply);
324 }
325 }
326
327
328
329 public class UserServerRequest
330 {
331 public UserServerRequest()
332 {
333
334 }
335 }
336}
diff --git a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsBase.cs b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsBase.cs
new file mode 100644
index 0000000..99b86d4
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsBase.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Interfaces;
6using OpenSim.Framework.Types;
7
8namespace OpenSim
9{
10 public class AuthenticateSessionsBase
11 {
12 public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
13
14 public AuthenticateSessionsBase()
15 {
16
17 }
18
19 public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
20 {
21 AgentCircuitData validcircuit = null;
22 if (this.AgentCircuits.ContainsKey(circuitcode))
23 {
24 validcircuit = this.AgentCircuits[circuitcode];
25 }
26 AuthenticateResponse user = new AuthenticateResponse();
27 if (validcircuit == null)
28 {
29 //don't have this circuit code in our list
30 user.Authorised = false;
31 return (user);
32 }
33
34 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
35 {
36 user.Authorised = true;
37 user.LoginInfo = new Login();
38 user.LoginInfo.Agent = agentID;
39 user.LoginInfo.Session = sessionID;
40 user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
41 user.LoginInfo.First = validcircuit.firstname;
42 user.LoginInfo.Last = validcircuit.lastname;
43 user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
44 user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
45 }
46 else
47 {
48 // Invalid
49 user.Authorised = false;
50 }
51
52 return (user);
53 }
54
55 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
56 {
57 if (this.AgentCircuits.ContainsKey(circuitCode))
58 {
59 this.AgentCircuits[circuitCode] = agentData;
60 }
61 else
62 {
63 this.AgentCircuits.Add(circuitCode, agentData);
64 }
65 }
66
67 public LLVector3 GetPosition(uint circuitCode)
68 {
69 LLVector3 vec = new LLVector3();
70 if (this.AgentCircuits.ContainsKey(circuitCode))
71 {
72 vec = this.AgentCircuits[circuitCode].startpos;
73 }
74 return vec;
75 }
76
77 public void UpdateAgentData(AgentCircuitData agentData)
78 {
79 if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode))
80 {
81 this.AgentCircuits[(uint)agentData.circuitcode].firstname = agentData.firstname;
82 this.AgentCircuits[(uint)agentData.circuitcode].lastname = agentData.lastname;
83 this.AgentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos;
84 // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
85 }
86 }
87
88 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
89 {
90 if (this.AgentCircuits.ContainsKey(circuitcode))
91 {
92 this.AgentCircuits[circuitcode].child = childstatus;
93 }
94 }
95
96 public bool GetAgentChildStatus(uint circuitcode)
97 {
98 if (this.AgentCircuits.ContainsKey(circuitcode))
99 {
100 return this.AgentCircuits[circuitcode].child;
101 }
102 return false;
103 }
104 }
105}
diff --git a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs
new file mode 100644
index 0000000..6c1c7d2
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsLocal.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Types;
6
7namespace OpenSim
8{
9 public class AuthenticateSessionsLocal : AuthenticateSessionsBase
10 {
11 public AuthenticateSessionsLocal()
12 {
13
14 }
15
16 public void AddNewSession(Login loginData)
17 {
18 AgentCircuitData agent = new AgentCircuitData();
19 agent.AgentID = loginData.Agent;
20 agent.firstname = loginData.First;
21 agent.lastname = loginData.Last;
22 agent.SessionID = loginData.Session;
23 agent.SecureSessionID = loginData.SecureSession;
24 agent.circuitcode = loginData.CircuitCode;
25 agent.BaseFolder = loginData.BaseFolder;
26 agent.InventoryFolder = loginData.InventoryFolder;
27 agent.startpos = new LLVector3(128,128,70);
28 this.AddNewCircuit(agent.circuitcode, agent);
29 }
30 }
31}
diff --git a/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs
new file mode 100644
index 0000000..0802d75
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/AuthenticateSessionsRemote.cs
@@ -0,0 +1,46 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using System.Xml;
6using libsecondlife;
7using OpenSim.Framework.Types;
8using Nwc.XmlRpc;
9
10namespace OpenSim
11{
12 public class AuthenticateSessionsRemote : AuthenticateSessionsBase
13 {
14 public AuthenticateSessionsRemote()
15 {
16
17 }
18
19 public XmlRpcResponse ExpectUser(XmlRpcRequest request)
20 {
21 Hashtable requestData = (Hashtable)request.Params[0];
22 AgentCircuitData agentData = new AgentCircuitData();
23 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
24 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
25 agentData.firstname = (string)requestData["firstname"];
26 agentData.lastname = (string)requestData["lastname"];
27 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
28 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
29 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
30 {
31 agentData.child = true;
32 }
33 else
34 {
35 agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
36 agentData.child = false;
37 // Console.WriteLine("expect user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
38
39 }
40
41 this.AddNewCircuit(agentData.circuitcode, agentData);
42
43 return new XmlRpcResponse();
44 }
45 }
46}
diff --git a/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
new file mode 100644
index 0000000..2299fa4
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
@@ -0,0 +1,256 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using OpenSim.world;
6using OpenSim.UserServer;
7using OpenSim.Servers;
8using OpenSim.Assets;
9using OpenSim.Framework.Inventory;
10using libsecondlife;
11using OpenSim.RegionServer.world.scripting;
12using Avatar=libsecondlife.Avatar;
13
14namespace OpenSim.CAPS
15{
16 public class AdminWebFront
17 {
18 private string AdminPage;
19 private string NewAccountForm;
20 private string LoginForm;
21 private string passWord = "Admin";
22 private World m_world;
23 private LoginServer _userServer;
24 private InventoryCache _inventoryCache;
25
26 public AdminWebFront(string password, World world, InventoryCache inventoryCache, LoginServer userserver)
27 {
28 _inventoryCache = inventoryCache;
29 _userServer = userserver;
30 m_world = world;
31 passWord = password;
32 LoadAdminPage();
33 }
34
35 public void LoadMethods( BaseHttpServer server )
36 {
37 server.AddRestHandler("GET", "/Admin", GetAdminPage);
38 server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage);
39 server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage );
40 server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage);
41 server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage);
42 server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage);
43 server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript );
44 server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory);
45
46 server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
47 server.AddRestHandler("POST", "/Admin/Login", PostLogin );
48 }
49
50 private string GetWelcomePage(string request, string path, string param)
51 {
52 string responseString;
53 responseString = "Welcome to the OpenSim Admin Page";
54 responseString += "<br><br><br> " + LoginForm;
55 return responseString;
56 }
57
58 private string PostLogin(string requestBody, string path, string param)
59 {
60 string responseString;
61// Console.WriteLine(requestBody);
62 if (requestBody == passWord)
63 {
64 responseString = "<p> Login Successful </p>";
65 }
66 else
67 {
68 responseString = "<p> Password Error </p>";
69 responseString += "<p> Please Login with the correct password </p>";
70 responseString += "<br><br> " + LoginForm;
71 }
72 return responseString;
73 }
74
75 private string PostNewAccount(string requestBody, string path, string param)
76 {
77 string responseString;
78 string firstName = "";
79 string secondName = "";
80 string userPasswd = "";
81 string[] comp;
82 string[] passw;
83 string[] line;
84 string delimStr = "&";
85 char[] delimiter = delimStr.ToCharArray();
86 string delimStr2 = "=";
87 char[] delimiter2 = delimStr2.ToCharArray();
88
89 //Console.WriteLine(requestBody);
90 comp = requestBody.Split(delimiter);
91 passw = comp[3].Split(delimiter2);
92 if (passw[1] == passWord) // check admin password is correct
93 {
94
95 line = comp[0].Split(delimiter2); //split firstname
96 if (line.Length > 1)
97 {
98 firstName = line[1];
99 }
100 line = comp[1].Split(delimiter2); //split secondname
101 if (line.Length > 1)
102 {
103 secondName = line[1];
104 }
105 line = comp[2].Split(delimiter2); //split user password
106 if (line.Length > 1)
107 {
108 userPasswd = line[1];
109 }
110 if (this._userServer != null)
111 {
112 this._userServer.CreateUserAccount(firstName, secondName, userPasswd);
113 }
114 responseString = "<p> New Account created </p>";
115 }
116 else
117 {
118 responseString = "<p> Admin password is incorrect, please login with the correct password</p>";
119 responseString += "<br><br>" + LoginForm;
120 }
121 return responseString;
122 }
123
124 private string GetConnectedClientsPage(string request, string path, string param)
125 {
126 string responseString;
127 responseString = " <p> Listing connected Clients </p>";
128 OpenSim.world.Avatar TempAv;
129 foreach (libsecondlife.LLUUID UUID in m_world.Entities.Keys)
130 {
131 if (m_world.Entities[UUID].ToString() == "OpenSim.world.Avatar")
132 {
133 TempAv = (OpenSim.world.Avatar)m_world.Entities[UUID];
134 responseString += "<p> Client: ";
135 responseString += TempAv.firstname + " , " + TempAv.lastname + " , <A HREF=\"javascript:loadXMLDoc('ClientInventory/" + UUID.ToString() + "')\">" + UUID + "</A> , " + TempAv.ControllingClient.SessionID + " , " + TempAv.ControllingClient.CircuitCode + " , " + TempAv.ControllingClient.userEP.ToString();
136 responseString += "</p>";
137 }
138 }
139 return responseString;
140 }
141
142 private string AddTestScript(string request, string path, string param)
143 {
144 int index = path.LastIndexOf('/');
145
146 string lluidStr = path.Substring(index+1);
147
148 LLUUID id;
149
150 if( LLUUID.TryParse( lluidStr, out id ) )
151 {
152 // This is just here for concept purposes... Remove!
153 m_world.AddScript( m_world.Entities[id], new FollowRandomAvatar());
154 return String.Format("Added new script to object [{0}]", id);
155 }
156 else
157 {
158 return String.Format("Couldn't parse [{0}]", lluidStr );
159 }
160 }
161
162 private string GetScriptsPage(string request, string path, string param)
163 {
164 return String.Empty;
165 }
166
167 private string GetEntitiesPage(string request, string path, string param)
168 {
169 string responseString;
170 responseString = " <p> Listing current entities</p><ul>";
171
172 foreach (Entity entity in m_world.Entities.Values)
173 {
174 string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');";
175 responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.Name, entity.Pos, testScriptLink );
176 }
177 responseString += "</ul>";
178 return responseString;
179 }
180
181 private string GetClientsInventory(string request, string path, string param)
182 {
183 string[] line;
184 string delimStr = "/";
185 char[] delimiter = delimStr.ToCharArray();
186 string responseString;
187 responseString = " <p> Listing Inventory </p>";
188
189 line = path.Split(delimiter);
190 if (line.Length > 2)
191 {
192 if (line[1] == "ClientInventory")
193 {
194 AgentInventory inven = this._inventoryCache.GetAgentsInventory(new libsecondlife.LLUUID(line[2]));
195 responseString += " <p> Client: " + inven.AgentID.ToStringHyphenated() +" </p>";
196 if (inven != null)
197 {
198 foreach (InventoryItem item in inven.InventoryItems.Values)
199 {
200 responseString += "<p> InventoryItem: ";
201 responseString += item.Name +" , "+ item.ItemID +" , "+ item.Type +" , "+ item.FolderID +" , "+ item.AssetID +" , "+ item.Description ;
202 responseString += "</p>";
203 }
204 }
205 }
206 }
207 return responseString;
208 }
209
210 private string GetCachedAssets(string request, string path, string param)
211 {
212 return "";
213 }
214
215 private string GetAccountsPage(string request, string path, string param)
216 {
217 string responseString;
218 responseString = "<p> Account management </p>";
219 responseString += "<br> ";
220 responseString += "<p> Create New Account </p>";
221 responseString += NewAccountForm;
222 return responseString;
223 }
224
225 private string GetAdminPage(string request, string path, string param)
226 {
227 return AdminPage;
228 }
229
230 private void LoadAdminPage()
231 {
232 try
233 {
234 StreamReader SR;
235
236 SR = File.OpenText("testadmin.htm");
237 AdminPage = SR.ReadToEnd();
238 SR.Close();
239
240 SR = File.OpenText("newaccountform.htm");
241 NewAccountForm = SR.ReadToEnd();
242 SR.Close();
243
244 SR = File.OpenText("login.htm");
245 LoginForm = SR.ReadToEnd();
246 SR.Close();
247 }
248 catch (Exception e)
249 {
250 Console.WriteLine(e.ToString());
251 }
252
253 }
254
255 }
256}
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs b/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
new file mode 100644
index 0000000..1121839
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
@@ -0,0 +1,167 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using Nwc.XmlRpc;
7using System.Net;
8using System.Net.Sockets;
9using System.IO;
10using System.Threading;
11using System.Timers;
12using OpenSim.Framework.Interfaces;
13using OpenSim.Framework.Types;
14using OpenSim.Framework.Inventory;
15using OpenSim.Framework.Utilities;
16using OpenSim.world;
17using OpenSim.Assets;
18
19namespace OpenSim
20{
21 public partial class ClientView
22 {
23
24 public void EnableNeighbours()
25 {
26 if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
27 {
28 Hashtable SimParams;
29 ArrayList SendParams;
30 XmlRpcRequest GridReq;
31 XmlRpcResponse GridResp;
32 List<Packet> enablePackets = new List<Packet>();
33
34 RemoteGridBase gridServer = (RemoteGridBase)this.m_gridServer;
35
36 foreach (Hashtable neighbour in gridServer.neighbours)
37 {
38 try
39 {
40 string neighbourIPStr = (string)neighbour["sim_ip"];
41 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse(neighbourIPStr);
42 ushort neighbourPort = (ushort)Convert.ToInt32(neighbour["sim_port"]);
43 string reqUrl = "http://" + neighbourIPStr + ":" + neighbourPort.ToString();
44
45 Console.WriteLine(reqUrl);
46
47 SimParams = new Hashtable();
48 SimParams["session_id"] = this.SessionID.ToString();
49 SimParams["secure_session_id"] = this.SecureSessionID.ToString();
50 SimParams["firstname"] = this.ClientAvatar.firstname;
51 SimParams["lastname"] = this.ClientAvatar.lastname;
52 SimParams["agent_id"] = this.AgentID.ToString();
53 SimParams["circuit_code"] = (Int32)this.CircuitCode;
54 SimParams["child_agent"] = "1";
55 SendParams = new ArrayList();
56 SendParams.Add(SimParams);
57
58 GridReq = new XmlRpcRequest("expect_user", SendParams);
59 GridResp = GridReq.Send(reqUrl, 3000);
60 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
61 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
62 enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
63
64
65 byte[] byteIP = neighbourIP.GetAddressBytes();
66 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
67 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
68 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
69 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
70 enablesimpacket.SimulatorInfo.Port = neighbourPort;
71 enablePackets.Add(enablesimpacket);
72 }
73 catch (Exception e)
74 {
75 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Could not connect to neighbour " + neighbour["sim_ip"] + ":" + neighbour["sim_port"] + ", continuing.");
76 }
77 }
78 Thread.Sleep(3000);
79 foreach (Packet enable in enablePackets)
80 {
81 this.OutPacket(enable);
82 }
83 enablePackets.Clear();
84
85 }
86 }
87
88 public void CrossSimBorder(LLVector3 avatarpos)
89 { // VERY VERY BASIC
90
91 LLVector3 newpos = avatarpos;
92 uint neighbourx = this.m_regionData.RegionLocX;
93 uint neighboury = this.m_regionData.RegionLocY;
94
95 if (avatarpos.X < 0)
96 {
97 neighbourx -= 1;
98 newpos.X = 254;
99 }
100 if (avatarpos.X > 255)
101 {
102 neighbourx += 1;
103 newpos.X = 1;
104 }
105 if (avatarpos.Y < 0)
106 {
107 neighboury -= 1;
108 newpos.Y = 254;
109 }
110 if (avatarpos.Y > 255)
111 {
112 neighboury += 1;
113 newpos.Y = 1;
114 }
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
116
117 Hashtable SimParams;
118 ArrayList SendParams;
119 XmlRpcRequest GridReq;
120 XmlRpcResponse GridResp;
121 foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
122 {
123 if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
124 {
125 Console.WriteLine("found the neighbouring sim");
126 SimParams = new Hashtable();
127 SimParams["firstname"] = this.ClientAvatar.firstname;
128 SimParams["lastname"] = this.ClientAvatar.lastname;
129 SimParams["circuit_code"] = this.CircuitCode.ToString();
130 SimParams["pos_x"] = newpos.X.ToString();
131 SimParams["pos_y"] = newpos.Y.ToString();
132 SimParams["pos_z"] = newpos.Z.ToString();
133 SendParams = new ArrayList();
134 SendParams.Add(SimParams);
135
136 GridReq = new XmlRpcRequest("agent_crossing", SendParams);
137 GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
138
139 CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
140 NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
141 NewSimPack.AgentData.AgentID = this.AgentID;
142 NewSimPack.AgentData.SessionID = this.SessionID;
143 NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
144 NewSimPack.Info.Position = newpos;
145 NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
146 NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
147 NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
148 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
149 byte[] byteIP = neighbourIP.GetAddressBytes();
150 NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
151 NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
152 NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
153 NewSimPack.RegionData.SimIP += (uint)byteIP[0];
154 NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
155 NewSimPack.RegionData.SeedCapability = new byte[0];
156 this.OutPacket(NewSimPack);
157 this.DowngradeClient();
158 /* lock (PacketQueue)
159 {
160 ProcessOutPacket(NewSimPack);
161 DowngradeClient();
162 }*/
163 }
164 }
165 }
166 }
167}
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..75fcf18
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs
@@ -0,0 +1,163 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using Nwc.XmlRpc;
7using System.Net;
8using System.Net.Sockets;
9using System.IO;
10using System.Threading;
11using System.Timers;
12using OpenSim.Framework.Interfaces;
13using OpenSim.Framework.Types;
14using OpenSim.Framework.Inventory;
15using OpenSim.Framework.Utilities;
16using OpenSim.world;
17using OpenSim.Assets;
18
19namespace OpenSim
20{
21 public partial class ClientView
22 {
23 protected virtual void RegisterLocalPacketHandlers()
24 {
25 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
26 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
27 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
28 }
29
30 protected virtual bool Logout(ClientView simClient, Packet packet)
31 {
32 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
33 //send reply to let the client logout
34 LogoutReplyPacket logReply = new LogoutReplyPacket();
35 logReply.AgentData.AgentID = this.AgentID;
36 logReply.AgentData.SessionID = this.SessionID;
37 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
38 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
39 logReply.InventoryData[0].ItemID = LLUUID.Zero;
40 OutPacket(logReply);
41 //tell all clients to kill our object
42 KillObjectPacket kill = new KillObjectPacket();
43 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
44 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
45 kill.ObjectData[0].ID = this.ClientAvatar.localid;
46 foreach (ClientView client in m_clientThreads.Values)
47 {
48 client.OutPacket(kill);
49 }
50 if (this.m_userServer != null)
51 {
52 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
53 }
54 else
55 {
56 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
57 }
58
59 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
60 /*lock (m_world.Entities)
61 {
62 m_world.Entities.Remove(this.AgentID);
63 }*/
64 m_world.RemoveViewerAgent(this);
65 //need to do other cleaning up here too
66 m_clientThreads.Remove(this.CircuitCode);
67 m_networkServer.RemoveClientCircuit(this.CircuitCode);
68 this.ClientThread.Abort();
69 return true;
70 }
71
72 protected bool AgentTextureCached(ClientView simclient, Packet packet)
73 {
74 // Console.WriteLine(packet.ToString());
75 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
76 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
77 cachedresp.AgentData.AgentID = this.AgentID;
78 cachedresp.AgentData.SessionID = this.SessionID;
79 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
80 this.cachedtextureserial++;
81 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
82 for (int i = 0; i < chechedtex.WearableData.Length; i++)
83 {
84 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
85 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
86 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
87 cachedresp.WearableData[i].HostName = new byte[0];
88 }
89 this.OutPacket(cachedresp);
90 return true;
91 }
92
93 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
94 {
95 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
96 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
97 {
98 if (multipleupdate.ObjectData[i].Type == 9) //change position
99 {
100 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
101 OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
102 //should update stored position of the prim
103 }
104 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
105 {
106 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
107 OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
108 }
109 else if (multipleupdate.ObjectData[i].Type == 13)//scale
110 {
111 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
112 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
113 }
114 }
115 return true;
116 }
117
118 public void RequestMapLayer() //should be getting the map layer from the grid server
119 {
120 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
121 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
122 mapReply.AgentData.AgentID = this.AgentID;
123 mapReply.AgentData.Flags = 0;
124 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
125 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
126 mapReply.LayerData[0].Bottom = 800;
127 mapReply.LayerData[0].Left = 800;
128 mapReply.LayerData[0].Top = 1200;
129 mapReply.LayerData[0].Right = 1200;
130 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
131 this.OutPacket(mapReply);
132 }
133
134 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
135 {
136 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
137 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
138 mbReply.AgentData.AgentID = this.AgentID;
139 int len;
140 if (simMapProfiles == null)
141 len = 0;
142 else
143 len = simMapProfiles.Count;
144
145 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
146 int iii;
147 for (iii = 0; iii < len; iii++)
148 {
149 Hashtable mp = (Hashtable)simMapProfiles[iii];
150 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
151 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
152 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
153 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
154 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
155 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
156 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
157 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
158 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
159 }
160 this.OutPacket(mbReply);
161 }
162 }
163}
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
new file mode 100644
index 0000000..977162f
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
@@ -0,0 +1,456 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using Nwc.XmlRpc;
7using System.Net;
8using System.Net.Sockets;
9using System.IO;
10using System.Threading;
11using System.Timers;
12using OpenSim.Framework.Interfaces;
13using OpenSim.Framework.Types;
14using OpenSim.Framework.Inventory;
15using OpenSim.Framework.Utilities;
16using OpenSim.world;
17using OpenSim.Assets;
18
19namespace OpenSim
20{
21 public partial class ClientView
22 {
23 public delegate void GenericCall(ClientView remoteClient);
24 public delegate void GenericCall2();
25 public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary.
26 public delegate void GenericCall4(Packet packet, ClientView remoteClient);
27 public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock);
28 public delegate void ObjectSelect(uint localID, ClientView remoteClient);
29 public delegate void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient);
30 public delegate void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient);
31 public delegate void UpdatePrimVector(uint localID, LLVector3 pos, ClientView remoteClient);
32 public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient);
33 public delegate void StatusChange(bool status);
34
35 public event ChatFromViewer OnChatFromViewer;
36 public event RezObject OnRezObject;
37 public event GenericCall4 OnDeRezObject;
38 public event ModifyTerrain OnModifyTerrain;
39 public event GenericCall OnRegionHandShakeReply;
40 public event GenericCall OnRequestWearables;
41 public event SetAppearance OnSetAppearance;
42 public event GenericCall2 OnCompleteMovementToRegion;
43 public event GenericCall3 OnAgentUpdate;
44 public event StartAnim OnStartAnim;
45 public event GenericCall OnRequestAvatarsData;
46 public event LinkObjects OnLinkObjects;
47 public event GenericCall4 OnAddPrim;
48 public event UpdateShape OnUpdatePrimShape;
49 public event ObjectSelect OnObjectSelect;
50 public event UpdatePrimFlags OnUpdatePrimFlags;
51 public event UpdatePrimTexture OnUpdatePrimTexture;
52 public event UpdatePrimVector OnUpdatePrimPosition;
53 public event UpdatePrimRotation OnUpdatePrimRotation;
54 public event UpdatePrimVector OnUpdatePrimScale;
55 public event StatusChange OnChildAgentStatus;
56 public event GenericCall2 OnStopMovement;
57
58 protected override void ProcessInPacket(Packet Pack)
59 {
60 ack_pack(Pack);
61 if (debug)
62 {
63 if (Pack.Type != PacketType.AgentUpdate)
64 {
65 Console.WriteLine(Pack.Type.ToString());
66 }
67 }
68
69 if (this.ProcessPacketMethod(Pack))
70 {
71 //there is a handler registered that handled this packet type
72 return;
73 }
74 else
75 {
76 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
77
78 switch (Pack.Type)
79 {
80 case PacketType.ViewerEffect:
81 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
82 foreach (ClientView client in m_clientThreads.Values)
83 {
84 if (client.AgentID != this.AgentID)
85 {
86 viewer.AgentData.AgentID = client.AgentID;
87 viewer.AgentData.SessionID = client.SessionID;
88 client.OutPacket(viewer);
89 }
90 }
91 break;
92
93 #region New Event System - World/Avatar
94 case PacketType.ChatFromViewer:
95 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
96 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
97 {
98 //empty message so don't bother with it
99 break;
100 }
101 string fromName = ClientAvatar.firstname + " " + ClientAvatar.lastname;
102 byte[] message = inchatpack.ChatData.Message;
103 byte type = inchatpack.ChatData.Type;
104 LLVector3 fromPos = ClientAvatar.Pos;
105 LLUUID fromAgentID = AgentID;
106 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
107 break;
108 case PacketType.RezObject:
109 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
110 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
111 if (inven != null)
112 {
113 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
114 {
115 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
116 if (asset != null)
117 {
118 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
119 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
120 }
121 }
122 }
123 break;
124 case PacketType.DeRezObject:
125 OnDeRezObject(Pack, this);
126 break;
127 case PacketType.ModifyLand:
128 ModifyLandPacket modify = (ModifyLandPacket)Pack;
129 if (modify.ParcelData.Length > 0)
130 {
131 OnModifyTerrain(modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
132 }
133 break;
134 case PacketType.RegionHandshakeReply:
135 OnRegionHandShakeReply(this);
136 break;
137 case PacketType.AgentWearablesRequest:
138 OnRequestWearables(this);
139 OnRequestAvatarsData(this);
140 break;
141 case PacketType.AgentSetAppearance:
142 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
143 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
144 break;
145 case PacketType.CompleteAgentMovement:
146 if (this.m_child) this.UpgradeClient();
147 OnCompleteMovementToRegion();
148 this.EnableNeighbours();
149 break;
150 case PacketType.AgentUpdate:
151 OnAgentUpdate(Pack);
152 break;
153 case PacketType.AgentAnimation:
154 if (!m_child)
155 {
156 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
157 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
158 {
159 if (AgentAni.AnimationList[i].StartAnim)
160 {
161 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
162 }
163 }
164 }
165 break;
166
167 #endregion
168
169 #region New Event System - Objects/Prims
170 case PacketType.ObjectLink:
171 // OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
172 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
173 uint parentprimid = 0;
174 List<uint> childrenprims = new List<uint>();
175 if (link.ObjectData.Length > 1)
176 {
177 parentprimid = link.ObjectData[0].ObjectLocalID;
178
179 for (int i = 1; i < link.ObjectData.Length; i++)
180 {
181 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
182 }
183 }
184 OnLinkObjects(parentprimid, childrenprims);
185 break;
186 case PacketType.ObjectAdd:
187 m_world.AddNewPrim((ObjectAddPacket)Pack, this);
188 OnAddPrim(Pack, this);
189 break;
190 case PacketType.ObjectShape:
191 ObjectShapePacket shape = (ObjectShapePacket)Pack;
192 for (int i = 0; i < shape.ObjectData.Length; i++)
193 {
194 OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]);
195 }
196 break;
197 case PacketType.ObjectSelect:
198 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
199 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
200 {
201 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
202 }
203 break;
204 case PacketType.ObjectFlagUpdate:
205 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
206 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
207 break;
208 case PacketType.ObjectImage:
209 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
210 for (int i = 0; i < imagePack.ObjectData.Length; i++)
211 {
212 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this);
213
214 }
215 break;
216 #endregion
217
218 #region Inventory/Asset/Other related packets
219 case PacketType.RequestImage:
220 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
221 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
222 {
223 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
224 }
225 break;
226 case PacketType.TransferRequest:
227 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
228 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
229 m_assetCache.AddAssetRequest(this, transfer);
230 break;
231 case PacketType.AssetUploadRequest:
232 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
233 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
234 break;
235 case PacketType.RequestXfer:
236 //Console.WriteLine(Pack.ToString());
237 break;
238 case PacketType.SendXferPacket:
239 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
240 break;
241 case PacketType.CreateInventoryFolder:
242 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
243 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
244 //Console.WriteLine(Pack.ToString());
245 break;
246 case PacketType.CreateInventoryItem:
247 //Console.WriteLine(Pack.ToString());
248 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
249 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
250 {
251 this.UploadAssets.CreateInventoryItem(createItem);
252 }
253 else
254 {
255 // Console.Write(Pack.ToString());
256 this.CreateInventoryItem(createItem);
257 }
258 break;
259 case PacketType.FetchInventory:
260 //Console.WriteLine("fetch item packet");
261 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
262 m_inventoryCache.FetchInventory(this, FetchInventory);
263 break;
264 case PacketType.FetchInventoryDescendents:
265 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
266 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
267 break;
268 case PacketType.UpdateInventoryItem:
269 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
270 //Console.WriteLine(Pack.ToString());
271 for (int i = 0; i < update.InventoryData.Length; i++)
272 {
273 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
274 {
275 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
276 if (asset != null)
277 {
278 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
279 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
280 }
281 else
282 {
283 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
284 if (asset != null)
285 {
286 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
287 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
288 }
289 else
290 {
291 //Console.WriteLine("trying to update inventory item, but asset is null");
292 }
293 }
294 }
295 else
296 {
297 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
298 }
299 }
300 break;
301 case PacketType.RequestTaskInventory:
302 // Console.WriteLine(Pack.ToString());
303 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
304 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
305 bool foundent = false;
306 foreach (Entity ent in m_world.Entities.Values)
307 {
308 if (ent.localid == requesttask.InventoryData.LocalID)
309 {
310 replytask.InventoryData.TaskID = ent.uuid;
311 replytask.InventoryData.Serial = 0;
312 replytask.InventoryData.Filename = new byte[0];
313 foundent = true;
314 }
315 }
316 if (foundent)
317 {
318 this.OutPacket(replytask);
319 }
320 break;
321 case PacketType.UpdateTaskInventory:
322 // Console.WriteLine(Pack.ToString());
323 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
324 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
325 if (myinventory != null)
326 {
327 if (updatetask.UpdateData.Key == 0)
328 {
329 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
330 {
331 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
332 {
333 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
334 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
335 if (assBase != null)
336 {
337 foreach (Entity ent in m_world.Entities.Values)
338 {
339 if (ent.localid == updatetask.UpdateData.LocalID)
340 {
341 if (ent is OpenSim.world.Primitive)
342 {
343 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
344 }
345 }
346 }
347 }
348 }
349 }
350 }
351 }
352 break;
353 case PacketType.MapLayerRequest:
354 this.RequestMapLayer();
355 break;
356 case PacketType.MapBlockRequest:
357 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
358
359 this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
360 break;
361 case PacketType.TeleportLandmarkRequest:
362 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
363
364 TeleportStartPacket tpStart = new TeleportStartPacket();
365 tpStart.Info.TeleportFlags = 8; // tp via lm
366 this.OutPacket(tpStart);
367
368 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
369 tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark");
370 tpProgress.Info.TeleportFlags = 8;
371 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
372 this.OutPacket(tpProgress);
373
374 // Fetch landmark
375 LLUUID lmid = tpReq.Info.LandmarkID;
376 AssetBase lma = this.m_assetCache.GetAsset(lmid);
377 if (lma != null)
378 {
379 AssetLandmark lm = new AssetLandmark(lma);
380
381 if (lm.RegionID == m_regionData.SimUUID)
382 {
383 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
384
385 tpLocal.Info.AgentID = tpReq.Info.AgentID;
386 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
387 tpLocal.Info.LocationID = 2;
388 tpLocal.Info.Position = lm.Position;
389 OutPacket(tpLocal);
390 }
391 else
392 {
393 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
394 tpCancel.Info.AgentID = tpReq.Info.AgentID;
395 tpCancel.Info.SessionID = tpReq.Info.SessionID;
396 OutPacket(tpCancel);
397 }
398 }
399 else
400 {
401 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
402
403 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
404 tpCancel.Info.AgentID = tpReq.Info.AgentID;
405 tpCancel.Info.SessionID = tpReq.Info.SessionID;
406 OutPacket(tpCancel);
407 }
408 break;
409 case PacketType.TeleportLocationRequest:
410 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
411 Console.WriteLine(tpLocReq.ToString());
412
413 tpStart = new TeleportStartPacket();
414 tpStart.Info.TeleportFlags = 16; // Teleport via location
415 Console.WriteLine(tpStart.ToString());
416 OutPacket(tpStart);
417
418 if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle)
419 {
420 /* m_gridServer.getRegion(tpLocReq.Info.RegionHandle); */
421 Console.WriteLine("Inter-sim teleport not yet implemented");
422 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
423 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
424 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
425
426 OutPacket(tpCancel);
427 }
428 else
429 {
430 Console.WriteLine("Local teleport");
431 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
432 tpLocal.Info.AgentID = tpLocReq.AgentData.AgentID;
433 tpLocal.Info.TeleportFlags = tpStart.Info.TeleportFlags;
434 tpLocal.Info.LocationID = 2;
435 tpLocal.Info.LookAt = tpLocReq.Info.LookAt;
436 tpLocal.Info.Position = tpLocReq.Info.Position;
437 OutPacket(tpLocal);
438
439 }
440 break;
441 #endregion
442
443 #region unimplemented handlers
444 case PacketType.AgentIsNowWearing:
445 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
446 //Console.WriteLine(Pack.ToString());
447 break;
448 case PacketType.ObjectScale:
449 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
450 break;
451 #endregion
452 }
453 }
454 }
455 }
456}
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs
new file mode 100644
index 0000000..295cd7b
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.cs
@@ -0,0 +1,449 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*/
26
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using libsecondlife;
31using libsecondlife.Packets;
32using Nwc.XmlRpc;
33using System.Net;
34using System.Net.Sockets;
35using System.IO;
36using System.Threading;
37using System.Timers;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Inventory;
41using OpenSim.Framework.Utilities;
42using OpenSim.world;
43using OpenSim.Assets;
44
45namespace OpenSim
46{
47 public delegate bool PacketMethod(ClientView simClient, Packet packet);
48
49 /// <summary>
50 /// Handles new client connections
51 /// Constructor takes a single Packet and authenticates everything
52 /// </summary>
53 public partial class ClientView : ClientViewBase, IClientAPI
54 {
55 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
56 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance
57
58 public LLUUID AgentID;
59 public LLUUID SessionID;
60 public LLUUID SecureSessionID = LLUUID.Zero;
61 public bool m_child;
62 public world.Avatar ClientAvatar;
63 private UseCircuitCodePacket cirpack;
64 public Thread ClientThread;
65 public LLVector3 startpos;
66
67 private AgentAssetUpload UploadAssets;
68 private LLUUID newAssetFolder = LLUUID.Zero;
69 private bool debug = false;
70 private World m_world;
71 private Dictionary<uint, ClientView> m_clientThreads;
72 private AssetCache m_assetCache;
73 private IGridServer m_gridServer;
74 private IUserServer m_userServer = null;
75 private InventoryCache m_inventoryCache;
76 public bool m_sandboxMode;
77 private int cachedtextureserial = 0;
78 private RegionInfo m_regionData;
79 protected AuthenticateSessionsBase m_authenticateSessionsHandler;
80
81 public IUserServer UserServer
82 {
83 set
84 {
85 this.m_userServer = value;
86 }
87 }
88
89 public LLVector3 StartPos
90 {
91 get
92 {
93 return startpos;
94 }
95 set
96 {
97 startpos = value;
98 }
99 }
100
101 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, ClientView> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions)
102 {
103 m_world = world;
104 m_clientThreads = clientThreads;
105 m_assetCache = assetCache;
106 m_gridServer = gridServer;
107 m_networkServer = application;
108 m_inventoryCache = inventoryCache;
109 m_sandboxMode = sandboxMode;
110 m_child = child;
111 m_regionData = regionDat;
112 m_authenticateSessionsHandler = authenSessions;
113
114 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs - Started up new client thread to handle incoming request");
115 cirpack = initialcirpack;
116 userEP = remoteEP;
117
118 if (m_gridServer.GetName() == "Remote")
119 {
120 this.m_child = m_authenticateSessionsHandler.GetAgentChildStatus(initialcirpack.CircuitCode.Code);
121 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code);
122 //Console.WriteLine("start pos is " + this.startpos.X + " , " + this.startpos.Y + " , " + this.startpos.Z);
123 }
124 else
125 {
126 this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 15.0f); // new LLVector3(128.0f, 128.0f, 60f);
127 }
128
129 PacketQueue = new BlockingQueue<QueItem>();
130
131 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
132 AckTimer = new System.Timers.Timer(500);
133 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
134 AckTimer.Start();
135
136 this.RegisterLocalPacketHandlers();
137
138 ClientThread = new Thread(new ThreadStart(AuthUser));
139 ClientThread.IsBackground = true;
140 ClientThread.Start();
141 }
142
143 # region Client Methods
144 public void UpgradeClient()
145 {
146 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - upgrading child to full agent");
147 this.m_child = false;
148 //this.m_world.RemoveViewerAgent(this);
149 if (!this.m_sandboxMode)
150 {
151 this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode);
152 m_authenticateSessionsHandler.UpdateAgentChildStatus(CircuitCode, false);
153 }
154 OnChildAgentStatus(this.m_child);
155 //this.InitNewClient();
156 }
157
158 public void DowngradeClient()
159 {
160 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - changing full agent to child");
161 this.m_child = true;
162 OnChildAgentStatus(this.m_child);
163 //this.m_world.RemoveViewerAgent(this);
164 //this.m_world.AddViewerAgent(this);
165 }
166
167 public void KillClient()
168 {
169 KillObjectPacket kill = new KillObjectPacket();
170 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
171 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
172 kill.ObjectData[0].ID = this.ClientAvatar.localid;
173 foreach (ClientView client in m_clientThreads.Values)
174 {
175 client.OutPacket(kill);
176 }
177 if (this.m_userServer != null)
178 {
179 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
180 }
181 else
182 {
183 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
184 }
185
186 m_world.RemoveViewerAgent(this);
187
188 m_clientThreads.Remove(this.CircuitCode);
189 m_networkServer.RemoveClientCircuit(this.CircuitCode);
190 this.ClientThread.Abort();
191 }
192 #endregion
193
194 # region Packet Handling
195 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
196 {
197 bool result = false;
198 lock (PacketHandlers)
199 {
200 if (!PacketHandlers.ContainsKey(packetType))
201 {
202 PacketHandlers.Add(packetType, handler);
203 result = true;
204 }
205 }
206 return result;
207 }
208
209 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
210 {
211 bool result = false;
212 lock (m_packetHandlers)
213 {
214 if (!m_packetHandlers.ContainsKey(packetType))
215 {
216 m_packetHandlers.Add(packetType, handler);
217 result = true;
218 }
219 }
220 return result;
221 }
222
223 protected virtual bool ProcessPacketMethod(Packet packet)
224 {
225 bool result = false;
226 bool found = false;
227 PacketMethod method;
228 if (m_packetHandlers.TryGetValue(packet.Type, out method))
229 {
230 //there is a local handler for this packet type
231 result = method(this, packet);
232 }
233 else
234 {
235 //there is not a local handler so see if there is a Global handler
236 lock (PacketHandlers)
237 {
238 found = PacketHandlers.TryGetValue(packet.Type, out method);
239 }
240 if (found)
241 {
242 result = method(this, packet);
243 }
244 }
245 return result;
246 }
247
248 protected virtual void ClientLoop()
249 {
250 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop");
251 while (true)
252 {
253 QueItem nextPacket = PacketQueue.Dequeue();
254 if (nextPacket.Incoming)
255 {
256 //is a incoming packet
257 ProcessInPacket(nextPacket.Packet);
258 }
259 else
260 {
261 //is a out going packet
262 ProcessOutPacket(nextPacket.Packet);
263 }
264 }
265 }
266 # endregion
267
268 # region Setup
269
270 protected virtual void InitNewClient()
271 {
272 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
273 this.ClientAvatar = m_world.AddViewerAgent(this);
274 }
275
276 protected virtual void AuthUser()
277 {
278 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
279 AuthenticateResponse sessionInfo = this.m_networkServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
280 if (!sessionInfo.Authorised)
281 {
282 //session/circuit not authorised
283 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
284 ClientThread.Abort();
285 }
286 else
287 {
288 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
289 //session is authorised
290 this.AgentID = cirpack.CircuitCode.ID;
291 this.SessionID = cirpack.CircuitCode.SessionID;
292 this.CircuitCode = cirpack.CircuitCode.Code;
293 InitNewClient();
294 this.ClientAvatar.firstname = sessionInfo.LoginInfo.First;
295 this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last;
296 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
297 {
298 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
299 }
300
301 // Create Inventory, currently only works for sandbox mode
302 if (m_sandboxMode)
303 {
304 this.SetupInventory(sessionInfo);
305 }
306
307 ClientLoop();
308 }
309 }
310 # endregion
311
312
313 protected override void KillThread()
314 {
315 this.ClientThread.Abort();
316 }
317
318 #region World/Avatar To Viewer Methods
319
320 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
321 {
322 System.Text.Encoding enc = System.Text.Encoding.ASCII;
323 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
324 reply.ChatData.Audible = 1;
325 reply.ChatData.Message = message;
326 reply.ChatData.ChatType = type;
327 reply.ChatData.SourceType = 1;
328 reply.ChatData.Position = fromPos;
329 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
330 reply.ChatData.OwnerID = fromAgentID;
331 reply.ChatData.SourceID = fromAgentID;
332
333 this.OutPacket(reply);
334 }
335
336 public void SendAppearance(AvatarWearable[] wearables)
337 {
338 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
339 aw.AgentData.AgentID = this.AgentID;
340 aw.AgentData.SerialNum = 0;
341 aw.AgentData.SessionID = this.SessionID;
342
343 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
344 AgentWearablesUpdatePacket.WearableDataBlock awb;
345 for (int i = 0; i < wearables.Length; i++)
346 {
347 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
348 awb.WearableType = (byte)i;
349 awb.AssetID = wearables[i].AssetID;
350 awb.ItemID = wearables[i].ItemID;
351 aw.WearableData[i] = awb;
352 }
353
354 this.OutPacket(aw);
355 }
356 #endregion
357
358 #region Inventory Creation
359 private void SetupInventory(AuthenticateResponse sessionInfo)
360 {
361 AgentInventory inventory = null;
362 if (sessionInfo.LoginInfo.InventoryFolder != null)
363 {
364 inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder);
365 if (sessionInfo.LoginInfo.BaseFolder != null)
366 {
367 if (!inventory.HasFolder(sessionInfo.LoginInfo.BaseFolder))
368 {
369 m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder);
370 }
371 this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder;
372 AssetBase[] inventorySet = m_assetCache.CreateNewInventorySet(this.AgentID);
373 if (inventorySet != null)
374 {
375 for (int i = 0; i < inventorySet.Length; i++)
376 {
377 if (inventorySet[i] != null)
378 {
379 m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]);
380 }
381 }
382 }
383 }
384 }
385 }
386 private AgentInventory CreateInventory(LLUUID baseFolder)
387 {
388 AgentInventory inventory = null;
389 if (this.m_userServer != null)
390 {
391 // a user server is set so request the inventory from it
392 Console.WriteLine("getting inventory from user server");
393 inventory = m_inventoryCache.FetchAgentsInventory(this.AgentID, m_userServer);
394 }
395 else
396 {
397 inventory = new AgentInventory();
398 inventory.AgentID = this.AgentID;
399 inventory.CreateRootFolder(this.AgentID, false);
400 m_inventoryCache.AddNewAgentsInventory(inventory);
401 m_inventoryCache.CreateNewInventoryFolder(this, baseFolder);
402 }
403 return inventory;
404 }
405
406 private void CreateInventoryItem(CreateInventoryItemPacket packet)
407 {
408 if (!(packet.InventoryBlock.Type == 3 || packet.InventoryBlock.Type == 7))
409 {
410 System.Console.WriteLine("Attempted to create " + Util.FieldToString(packet.InventoryBlock.Name) + " in inventory. Unsupported type");
411 return;
412 }
413
414 //lets try this out with creating a notecard
415 AssetBase asset = new AssetBase();
416
417 asset.Name = Util.FieldToString(packet.InventoryBlock.Name);
418 asset.Description = Util.FieldToString(packet.InventoryBlock.Description);
419 asset.InvType = packet.InventoryBlock.InvType;
420 asset.Type = packet.InventoryBlock.Type;
421 asset.FullID = LLUUID.Random();
422
423 switch (packet.InventoryBlock.Type)
424 {
425 case 7: // Notecard
426 asset.Data = new byte[0];
427 break;
428
429 case 3: // Landmark
430 String content;
431 content = "Landmark version 2\n";
432 content += "region_id " + m_regionData.SimUUID + "\n";
433 String strPos = String.Format("%.2f %.2f %.2f>",
434 this.ClientAvatar.Pos.X,
435 this.ClientAvatar.Pos.Y,
436 this.ClientAvatar.Pos.Z);
437 content += "local_pos " + strPos + "\n";
438 asset.Data = (new System.Text.ASCIIEncoding()).GetBytes(content);
439 break;
440 default:
441 break;
442 }
443 m_assetCache.AddAsset(asset);
444 m_inventoryCache.AddNewInventoryItem(this, packet.InventoryBlock.FolderID, asset);
445 }
446 #endregion
447
448 }
449}
diff --git a/OpenSim/OpenSim.RegionServer/ClientViewBase.cs b/OpenSim/OpenSim.RegionServer/ClientViewBase.cs
new file mode 100644
index 0000000..572dbce
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientViewBase.cs
@@ -0,0 +1,299 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using System.Net;
7using System.Net.Sockets;
8using System.IO;
9using System.Threading;
10using System.Timers;
11using OpenSim.Framework.Utilities;
12using OpenSim.Framework.Interfaces;
13
14namespace OpenSim
15{
16 public class ClientViewBase
17 {
18 protected BlockingQueue<QueItem> PacketQueue;
19 protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
20 protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
21
22 protected System.Timers.Timer AckTimer;
23 protected uint Sequence = 0;
24 protected object SequenceLock = new object();
25 protected const int MAX_APPENDED_ACKS = 10;
26 protected const int RESEND_TIMEOUT = 4000;
27 protected const int MAX_SEQUENCE = 0xFFFFFF;
28
29 public uint CircuitCode;
30 public EndPoint userEP;
31
32 protected OpenSimNetworkHandler m_networkServer;
33
34 public ClientViewBase()
35 {
36
37 }
38
39 protected virtual void ProcessInPacket(Packet Pack)
40 {
41
42 }
43
44 protected virtual void ProcessOutPacket(Packet Pack)
45 {
46 // Keep track of when this packet was sent out
47 Pack.TickCount = Environment.TickCount;
48
49 if (!Pack.Header.Resent)
50 {
51 // Set the sequence number
52 lock (SequenceLock)
53 {
54 if (Sequence >= MAX_SEQUENCE)
55 Sequence = 1;
56 else
57 Sequence++;
58 Pack.Header.Sequence = Sequence;
59 }
60
61 if (Pack.Header.Reliable) //DIRTY HACK
62 {
63 lock (NeedAck)
64 {
65 if (!NeedAck.ContainsKey(Pack.Header.Sequence))
66 {
67 try
68 {
69 NeedAck.Add(Pack.Header.Sequence, Pack);
70 }
71 catch (Exception e) // HACKY
72 {
73 e.ToString();
74 // Ignore
75 // Seems to throw a exception here occasionally
76 // of 'duplicate key' despite being locked.
77 // !?!?!?
78 }
79 }
80 else
81 {
82 // Client.Log("Attempted to add a duplicate sequence number (" +
83 // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
84 // packet.Type.ToString(), Helpers.LogLevel.Warning);
85 }
86 }
87
88 // Don't append ACKs to resent packets, in case that's what was causing the
89 // delivery to fail
90 if (!Pack.Header.Resent)
91 {
92 // Append any ACKs that need to be sent out to this packet
93 lock (PendingAcks)
94 {
95 if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
96 Pack.Type != PacketType.PacketAck &&
97 Pack.Type != PacketType.LogoutRequest)
98 {
99 Pack.Header.AckList = new uint[PendingAcks.Count];
100 int i = 0;
101
102 foreach (uint ack in PendingAcks.Values)
103 {
104 Pack.Header.AckList[i] = ack;
105 i++;
106 }
107
108 PendingAcks.Clear();
109 Pack.Header.AppendedAcks = true;
110 }
111 }
112 }
113 }
114 }
115
116 byte[] ZeroOutBuffer = new byte[4096];
117 byte[] sendbuffer;
118 sendbuffer = Pack.ToBytes();
119
120 try
121 {
122 if (Pack.Header.Zerocoded)
123 {
124 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
125 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
126 }
127 else
128 {
129 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
130 }
131 }
132 catch (Exception)
133 {
134 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
135 this.KillThread();
136 }
137
138 }
139
140 public virtual void InPacket(Packet NewPack)
141 {
142 // Handle appended ACKs
143 if (NewPack.Header.AppendedAcks)
144 {
145 lock (NeedAck)
146 {
147 foreach (uint ack in NewPack.Header.AckList)
148 {
149 NeedAck.Remove(ack);
150 }
151 }
152 }
153
154 // Handle PacketAck packets
155 if (NewPack.Type == PacketType.PacketAck)
156 {
157 PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
158
159 lock (NeedAck)
160 {
161 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
162 {
163 NeedAck.Remove(block.ID);
164 }
165 }
166 }
167 else if ((NewPack.Type == PacketType.StartPingCheck))
168 {
169 //reply to pingcheck
170 libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack;
171 libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket();
172 endPing.PingID.PingID = startPing.PingID.PingID;
173 OutPacket(endPing);
174 }
175 else
176 {
177 QueItem item = new QueItem();
178 item.Packet = NewPack;
179 item.Incoming = true;
180 this.PacketQueue.Enqueue(item);
181 }
182
183 }
184
185 public virtual void OutPacket(Packet NewPack)
186 {
187 QueItem item = new QueItem();
188 item.Packet = NewPack;
189 item.Incoming = false;
190 this.PacketQueue.Enqueue(item);
191 }
192
193 # region Low Level Packet Methods
194
195 protected void ack_pack(Packet Pack)
196 {
197 if (Pack.Header.Reliable)
198 {
199 libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
200 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
201 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
202 ack_it.Packets[0].ID = Pack.Header.Sequence;
203 ack_it.Header.Reliable = false;
204
205 OutPacket(ack_it);
206
207 }
208 /*
209 if (Pack.Header.Reliable)
210 {
211 lock (PendingAcks)
212 {
213 uint sequence = (uint)Pack.Header.Sequence;
214 if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
215 }
216 }*/
217 }
218
219 protected void ResendUnacked()
220 {
221 int now = Environment.TickCount;
222
223 lock (NeedAck)
224 {
225 foreach (Packet packet in NeedAck.Values)
226 {
227 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
228 {
229 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " +
230 (now - packet.TickCount) + "ms have passed");
231
232 packet.Header.Resent = true;
233 OutPacket(packet);
234 }
235 }
236 }
237 }
238
239 protected void SendAcks()
240 {
241 lock (PendingAcks)
242 {
243 if (PendingAcks.Count > 0)
244 {
245 if (PendingAcks.Count > 250)
246 {
247 // FIXME: Handle the odd case where we have too many pending ACKs queued up
248 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!");
249 return;
250 }
251
252 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck");
253
254
255 int i = 0;
256 PacketAckPacket acks = new PacketAckPacket();
257 acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
258
259 foreach (uint ack in PendingAcks.Values)
260 {
261 acks.Packets[i] = new PacketAckPacket.PacketsBlock();
262 acks.Packets[i].ID = ack;
263 i++;
264 }
265
266 acks.Header.Reliable = false;
267 OutPacket(acks);
268
269 PendingAcks.Clear();
270 }
271 }
272 }
273
274 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
275 {
276 SendAcks();
277 ResendUnacked();
278 }
279 #endregion
280
281 protected virtual void KillThread()
282 {
283
284 }
285
286 #region Nested Classes
287
288 public class QueItem
289 {
290 public QueItem()
291 {
292 }
293
294 public Packet Packet;
295 public bool Incoming;
296 }
297 #endregion
298 }
299}
diff --git a/OpenSim/OpenSim.RegionServer/Grid.cs b/OpenSim/OpenSim.RegionServer/Grid.cs
new file mode 100644
index 0000000..db5b8fe
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/Grid.cs
@@ -0,0 +1,90 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Reflection;
5using OpenSim.Framework.Interfaces;
6using OpenSim.UserServer;
7
8namespace OpenSim
9{
10 public class Grid
11 {
12 public IAssetServer AssetServer;
13 public IGridServer GridServer;
14 public IUserServer UserServer;
15 public string AssetDll = "";
16 public string GridDll = "";
17
18 public Grid()
19 {
20 }
21
22 public virtual void Initialise()
23 {
24 //load the dlls
25 this.AssetServer = this.LoadAssetDll(this.AssetDll);
26 this.GridServer = this.LoadGridDll(this.GridDll);
27 }
28 public virtual void Close()
29 {
30 this.AssetServer.Close();
31 this.GridServer.Close();
32 }
33
34 private IAssetServer LoadAssetDll(string dllName)
35 {
36 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
37 IAssetServer server = null;
38
39 foreach (Type pluginType in pluginAssembly.GetTypes())
40 {
41 if (pluginType.IsPublic)
42 {
43 if (!pluginType.IsAbstract)
44 {
45 Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
46
47 if (typeInterface != null)
48 {
49 IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
50 server = plug.GetAssetServer();
51 break;
52 }
53
54 typeInterface = null;
55 }
56 }
57 }
58 pluginAssembly = null;
59 return server;
60 }
61
62 private IGridServer LoadGridDll(string dllName)
63 {
64 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
65 IGridServer server = null;
66
67 foreach (Type pluginType in pluginAssembly.GetTypes())
68 {
69 if (pluginType.IsPublic)
70 {
71 if (!pluginType.IsAbstract)
72 {
73 Type typeInterface = pluginType.GetInterface("IGridPlugin", true);
74
75 if (typeInterface != null)
76 {
77 IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
78 server = plug.GetGridServer();
79 break;
80 }
81
82 typeInterface = null;
83 }
84 }
85 }
86 pluginAssembly = null;
87 return server;
88 }
89 }
90}
diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj
new file mode 100644
index 0000000..f06e16a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -0,0 +1,258 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{632E1BFD-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.RegionServer</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.RegionServer</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Axiom.MathLib.dll" >
74 <HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Db4objects.Db4o.dll" >
78 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
84 <Name>OpenSim.Terrain.BasicTerrain</Name>
85 <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
90 <Name>OpenSim.Framework</Name>
91 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 <ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
96 <Name>OpenSim.Framework.Console</Name>
97 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private>
100 </ProjectReference>
101 <ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
102 <Name>OpenSim.GenericConfig.Xml</Name>
103 <Project>{E88EF749-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private>
106 </ProjectReference>
107 <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
108 <Name>OpenSim.Physics.Manager</Name>
109 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 <ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj">
114 <Name>OpenSim.Servers</Name>
115 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
116 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
117 <Private>False</Private>
118 </ProjectReference>
119 <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj">
120 <Name>XMLRPC</Name>
121 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
122 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
123 <Private>False</Private>
124 </ProjectReference>
125 </ItemGroup>
126 <ItemGroup>
127 <Compile Include="AgentAssetUpload.cs">
128 <SubType>Code</SubType>
129 </Compile>
130 <Compile Include="AuthenticateSessionsBase.cs">
131 <SubType>Code</SubType>
132 </Compile>
133 <Compile Include="AuthenticateSessionsLocal.cs">
134 <SubType>Code</SubType>
135 </Compile>
136 <Compile Include="AuthenticateSessionsRemote.cs">
137 <SubType>Code</SubType>
138 </Compile>
139 <Compile Include="ClientView.cs">
140 <SubType>Code</SubType>
141 </Compile>
142 <Compile Include="ClientView.Grid.cs">
143 <SubType>Code</SubType>
144 </Compile>
145 <Compile Include="ClientView.PacketHandlers.cs">
146 <SubType>Code</SubType>
147 </Compile>
148 <Compile Include="ClientView.ProcessPackets.cs">
149 <SubType>Code</SubType>
150 </Compile>
151 <Compile Include="ClientViewBase.cs">
152 <SubType>Code</SubType>
153 </Compile>
154 <Compile Include="Grid.cs">
155 <SubType>Code</SubType>
156 </Compile>
157 <Compile Include="OpenSimMain.cs">
158 <SubType>Code</SubType>
159 </Compile>
160 <Compile Include="OpenSimNetworkHandler.cs">
161 <SubType>Code</SubType>
162 </Compile>
163 <Compile Include="PacketServer.cs">
164 <SubType>Code</SubType>
165 </Compile>
166 <Compile Include="RegionInfo.cs">
167 <SubType>Code</SubType>
168 </Compile>
169 <Compile Include="RegionInfoBase.cs">
170 <SubType>Code</SubType>
171 </Compile>
172 <Compile Include="RegionServerBase.cs">
173 <SubType>Code</SubType>
174 </Compile>
175 <Compile Include="UDPServer.cs">
176 <SubType>Code</SubType>
177 </Compile>
178 <Compile Include="VersionInfo.cs">
179 <SubType>Code</SubType>
180 </Compile>
181 <Compile Include="Assets\AssetCache.cs">
182 <SubType>Code</SubType>
183 </Compile>
184 <Compile Include="Assets\InventoryCache.cs">
185 <SubType>Code</SubType>
186 </Compile>
187 <Compile Include="CAPS\AdminWebFront.cs">
188 <SubType>Code</SubType>
189 </Compile>
190 <Compile Include="types\Mesh.cs">
191 <SubType>Code</SubType>
192 </Compile>
193 <Compile Include="types\Triangle.cs">
194 <SubType>Code</SubType>
195 </Compile>
196 <Compile Include="world\Avatar.Client.cs">
197 <SubType>Code</SubType>
198 </Compile>
199 <Compile Include="world\Avatar.cs">
200 <SubType>Code</SubType>
201 </Compile>
202 <Compile Include="world\Avatar.Update.cs">
203 <SubType>Code</SubType>
204 </Compile>
205 <Compile Include="world\AvatarAnimations.cs">
206 <SubType>Code</SubType>
207 </Compile>
208 <Compile Include="world\Entity.cs">
209 <SubType>Code</SubType>
210 </Compile>
211 <Compile Include="world\Primitive.cs">
212 <SubType>Code</SubType>
213 </Compile>
214 <Compile Include="world\Primitive2.cs">
215 <SubType>Code</SubType>
216 </Compile>
217 <Compile Include="world\SceneObject.cs">
218 <SubType>Code</SubType>
219 </Compile>
220 <Compile Include="world\World.cs">
221 <SubType>Code</SubType>
222 </Compile>
223 <Compile Include="world\World.PacketHandlers.cs">
224 <SubType>Code</SubType>
225 </Compile>
226 <Compile Include="world\World.Scripting.cs">
227 <SubType>Code</SubType>
228 </Compile>
229 <Compile Include="world\WorldBase.cs">
230 <SubType>Code</SubType>
231 </Compile>
232 <Compile Include="world\scripting\IScriptContext.cs">
233 <SubType>Code</SubType>
234 </Compile>
235 <Compile Include="world\scripting\IScriptEntity.cs">
236 <SubType>Code</SubType>
237 </Compile>
238 <Compile Include="world\scripting\IScriptHandler.cs">
239 <SubType>Code</SubType>
240 </Compile>
241 <Compile Include="world\scripting\Script.cs">
242 <SubType>Code</SubType>
243 </Compile>
244 <Compile Include="world\scripting\ScriptFactory.cs">
245 <SubType>Code</SubType>
246 </Compile>
247 <Compile Include="world\scripting\Scripts\FollowRandomAvatar.cs">
248 <SubType>Code</SubType>
249 </Compile>
250 </ItemGroup>
251 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
252 <PropertyGroup>
253 <PreBuildEvent>
254 </PreBuildEvent>
255 <PostBuildEvent>
256 </PostBuildEvent>
257 </PropertyGroup>
258</Project>
diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
new file mode 100644
index 0000000..c984f5a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -0,0 +1,90 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.RegionServer" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.RegionServer" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AgentAssetUpload.cs" />
15 <include name="AuthenticateSessionsBase.cs" />
16 <include name="AuthenticateSessionsLocal.cs" />
17 <include name="AuthenticateSessionsRemote.cs" />
18 <include name="ClientView.cs" />
19 <include name="ClientView.Grid.cs" />
20 <include name="ClientView.PacketHandlers.cs" />
21 <include name="ClientView.ProcessPackets.cs" />
22 <include name="ClientViewBase.cs" />
23 <include name="Grid.cs" />
24 <include name="OpenSimMain.cs" />
25 <include name="OpenSimNetworkHandler.cs" />
26 <include name="PacketServer.cs" />
27 <include name="RegionInfo.cs" />
28 <include name="RegionInfoBase.cs" />
29 <include name="RegionServerBase.cs" />
30 <include name="UDPServer.cs" />
31 <include name="VersionInfo.cs" />
32 <include name="Assets/AssetCache.cs" />
33 <include name="Assets/InventoryCache.cs" />
34 <include name="CAPS/AdminWebFront.cs" />
35 <include name="types/Mesh.cs" />
36 <include name="types/Triangle.cs" />
37 <include name="world/Avatar.Client.cs" />
38 <include name="world/Avatar.cs" />
39 <include name="world/Avatar.Update.cs" />
40 <include name="world/AvatarAnimations.cs" />
41 <include name="world/Entity.cs" />
42 <include name="world/Primitive.cs" />
43 <include name="world/Primitive2.cs" />
44 <include name="world/SceneObject.cs" />
45 <include name="world/World.cs" />
46 <include name="world/World.PacketHandlers.cs" />
47 <include name="world/World.Scripting.cs" />
48 <include name="world/WorldBase.cs" />
49 <include name="world/scripting/IScriptContext.cs" />
50 <include name="world/scripting/IScriptEntity.cs" />
51 <include name="world/scripting/IScriptHandler.cs" />
52 <include name="world/scripting/Script.cs" />
53 <include name="world/scripting/ScriptFactory.cs" />
54 <include name="world/scripting/Scripts/FollowRandomAvatar.cs" />
55 </sources>
56 <references basedir="${project::get-base-directory()}">
57 <lib>
58 <include name="${project::get-base-directory()}" />
59 <include name="${project::get-base-directory()}/${build.dir}" />
60 </lib>
61 <include name="System.dll" />
62 <include name="System.Xml.dll" />
63 <include name="../../bin/libsecondlife.dll" />
64 <include name="../../bin/Axiom.MathLib.dll" />
65 <include name="../../bin/Db4objects.Db4o.dll" />
66 <include name="../../bin/OpenSim.Terrain.BasicTerrain.dll" />
67 <include name="../../bin/OpenSim.Framework.dll" />
68 <include name="../../bin/OpenSim.Framework.Console.dll" />
69 <include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
70 <include name="../../bin/OpenSim.Physics.Manager.dll" />
71 <include name="../../bin/OpenSim.Servers.dll" />
72 <include name="../../bin/XMLRPC.dll" />
73 </references>
74 </csc>
75 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
76 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
77 <copy todir="${project::get-base-directory()}/../../bin/">
78 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
79 <include name="*.dll"/>
80 <include name="*.exe"/>
81 </fileset>
82 </copy>
83 </target>
84 <target name="clean">
85 <delete dir="${bin.dir}" failonerror="false" />
86 <delete dir="${obj.dir}" failonerror="false" />
87 </target>
88 <target name="doc" description="Creates documentation.">
89 </target>
90</project>
diff --git a/OpenSim/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim/OpenSim.RegionServer/OpenSimMain.cs
new file mode 100644
index 0000000..003412d
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/OpenSimMain.cs
@@ -0,0 +1,531 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* All rights reserved.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the <organization> nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29using System;
30using System.Text;
31using System.IO;
32using System.Threading;
33using System.Net;
34using System.Net.Sockets;
35using System.Timers;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using libsecondlife.Packets;
41using OpenSim.world;
42using OpenSim.Terrain;
43using OpenSim.Framework.Interfaces;
44using OpenSim.Framework.Types;
45using OpenSim.UserServer;
46using OpenSim.Assets;
47using OpenSim.CAPS;
48using OpenSim.Framework.Console;
49using OpenSim.Physics.Manager;
50using Nwc.XmlRpc;
51using OpenSim.Servers;
52using OpenSim.GenericConfig;
53
54namespace OpenSim
55{
56 //moved to the opensim main application project (do we want it there or here?)
57/*
58 public class OpenSimMain : OpenSimApplicationBase , conscmd_callback
59 {
60
61 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
62 {
63 this.configFileSetup = useConfigFile;
64 m_sandbox = sandBoxMode;
65 m_loginserver = startLoginServer;
66 m_physicsEngine = physicsEngine;
67 m_config = configFile;
68
69 m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent);
70 OpenSim.Framework.Console.MainConsole.Instance = m_console;
71 }
72
73 /// <summary>
74 /// Performs initialisation of the world, such as loading configuration from disk.
75 /// </summary>
76 public override void StartUp()
77 {
78 this.regionData = new RegionInfo();
79 try
80 {
81 this.localConfig = new XmlConfig(m_config);
82 this.localConfig.LoadData();
83 }
84 catch (Exception e)
85 {
86 Console.WriteLine(e.Message);
87 }
88 if (this.configFileSetup)
89 {
90 this.SetupFromConfigFile(this.localConfig);
91 }
92 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
93 this.regionData.InitConfig(this.m_sandbox, this.localConfig);
94 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
95
96 GridServers = new Grid();
97 if (m_sandbox)
98 {
99 this.SetupLocalGridServers();
100 //Authenticate Session Handler
101 AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal();
102 this.AuthenticateSessionsHandler = authen;
103 }
104 else
105 {
106 this.SetupRemoteGridServers();
107 //Authenticate Session Handler
108 AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote();
109 this.AuthenticateSessionsHandler = authen;
110 }
111
112 startuptime = DateTime.Now;
113
114 try
115 {
116 AssetCache = new AssetCache(GridServers.AssetServer);
117 InventoryCache = new InventoryCache();
118 }
119 catch (Exception e)
120 {
121 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache");
122 Environment.Exit(1);
123 }
124
125 m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler);
126
127 //should be passing a IGenericConfig object to these so they can read the config data they want from it
128 GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
129 IGridServer gridServer = GridServers.GridServer;
130 gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
131
132 if (!m_sandbox)
133 {
134 this.ConnectToRemoteGridServer();
135 }
136
137 this.SetupLocalWorld();
138
139 if (m_sandbox)
140 {
141 AssetCache.LoadDefaultTextureSet();
142 }
143
144 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
145
146 this.SetupHttpListener();
147
148 LoginServer loginServer = null;
149 LoginServer adminLoginServer = null;
150
151 bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
152 if (sandBoxWithLoginServer)
153 {
154 loginServer = new LoginServer( regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
155 loginServer.Startup();
156 loginServer.SetSessionHandler(((AuthenticateSessionsLocal) this.AuthenticateSessionsHandler).AddNewSession);
157
158 if (user_accounts)
159 {
160 //sandbox mode with loginserver using accounts
161 this.GridServers.UserServer = loginServer;
162 adminLoginServer = loginServer;
163
164 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
165 }
166 else
167 {
168 //sandbox mode with loginserver not using accounts
169 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
170 }
171 }
172
173 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
174 adminWebFront.LoadMethods(httpServer);
175
176 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
177 httpServer.Start();
178
179 //MainServerListener();
180 this.m_udpServer.ServerListener();
181
182 m_heartbeatTimer.Enabled = true;
183 m_heartbeatTimer.Interval = 100;
184 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
185 }
186
187 # region Setup methods
188 protected virtual void SetupLocalGridServers()
189 {
190 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
191 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
192
193 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
194
195 try
196 {
197 GridServers.Initialise();
198 }
199 catch (Exception e)
200 {
201 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
202 Environment.Exit(1);
203 }
204 }
205
206 protected virtual void SetupRemoteGridServers()
207 {
208 if (this.gridLocalAsset)
209 {
210 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
211 }
212 else
213 {
214 GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
215 }
216 GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
217
218 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
219
220 try
221 {
222 GridServers.Initialise();
223 }
224 catch (Exception e)
225 {
226 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
227 Environment.Exit(1);
228 }
229 }
230
231 protected virtual void SetupLocalWorld()
232 {
233 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
234 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
235 m_console.componentname = "Region " + regionData.RegionName;
236
237 m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
238 LocalWorld.InventoryCache = InventoryCache;
239 LocalWorld.AssetCache = AssetCache;
240
241 this.m_udpServer.LocalWorld = LocalWorld;
242 this.m_udpServer.PacketServer.RegisterClientPacketHandlers();
243
244 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
245 this.physManager.LoadPlugins();
246
247 LocalWorld.m_datastore = this.regionData.DataStore;
248
249 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
250 LocalWorld.LoadWorldMap();
251
252 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
253 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
254 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
255 LocalWorld.LoadPrimsFromStorage();
256 }
257
258 protected virtual void SetupHttpListener()
259 {
260 httpServer = new BaseHttpServer(regionData.IPListenPort);
261
262 if (this.GridServers.GridServer.GetName() == "Remote")
263 {
264
265 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
266 httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser );
267
268 httpServer.AddXmlRPCHandler("agent_crossing",
269 delegate(XmlRpcRequest request)
270 {
271 Hashtable requestData = (Hashtable)request.Params[0];
272 AgentCircuitData agent_data = new AgentCircuitData();
273 agent_data.firstname = (string)requestData["firstname"];
274 agent_data.lastname = (string)requestData["lastname"];
275 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
276 agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
277
278 if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
279 {
280 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
281 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
282 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
283 }
284
285 return new XmlRpcResponse();
286 });
287
288 httpServer.AddRestHandler("GET", "/simstatus/",
289 delegate(string request, string path, string param)
290 {
291 return "OK";
292 });
293 }
294 }
295
296 protected virtual void ConnectToRemoteGridServer()
297 {
298 if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
299 {
300 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!");
301 }
302 else
303 {
304 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
305 Shutdown();
306 }
307
308 GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
309
310 // If we are being told to load a file, load it.
311 string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
312
313 if (!String.IsNullOrEmpty(dataUri))
314 {
315 this.LocalWorld.m_datastore = dataUri;
316 }
317
318 if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
319 {
320 // The grid server has told us who we are
321 // We must obey the grid server.
322 try
323 {
324 regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
325 regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
326 regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
327 }
328 catch (Exception e)
329 {
330 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
331 Environment.Exit(1);
332 }
333 }
334 }
335
336 #endregion
337
338 private void SetupFromConfigFile(IGenericConfig configData)
339 {
340 try
341 {
342 // SandBoxMode
343 string attri = "";
344 attri = configData.GetAttribute("SandBox");
345 if ((attri == "") || ((attri != "false") && (attri != "true")))
346 {
347 this.m_sandbox = false;
348 configData.SetAttribute("SandBox", "false");
349 }
350 else
351 {
352 this.m_sandbox = Convert.ToBoolean(attri);
353 }
354
355 // LoginServer
356 attri = "";
357 attri = configData.GetAttribute("LoginServer");
358 if ((attri == "") || ((attri != "false") && (attri != "true")))
359 {
360 this.m_loginserver = false;
361 configData.SetAttribute("LoginServer", "false");
362 }
363 else
364 {
365 this.m_loginserver = Convert.ToBoolean(attri);
366 }
367
368 // Sandbox User accounts
369 attri = "";
370 attri = configData.GetAttribute("UserAccount");
371 if ((attri == "") || ((attri != "false") && (attri != "true")))
372 {
373 this.user_accounts = false;
374 configData.SetAttribute("UserAccounts", "false");
375 }
376 else if (attri == "true")
377 {
378 this.user_accounts = Convert.ToBoolean(attri);
379 }
380
381 // Grid mode hack to use local asset server
382 attri = "";
383 attri = configData.GetAttribute("LocalAssets");
384 if ((attri == "") || ((attri != "false") && (attri != "true")))
385 {
386 this.gridLocalAsset = false;
387 configData.SetAttribute("LocalAssets", "false");
388 }
389 else if (attri == "true")
390 {
391 this.gridLocalAsset = Convert.ToBoolean(attri);
392 }
393
394
395 attri = "";
396 attri = configData.GetAttribute("PhysicsEngine");
397 switch (attri)
398 {
399 default:
400 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
401 Environment.Exit(1);
402 break;
403
404 case "":
405 this.m_physicsEngine = "basicphysics";
406 configData.SetAttribute("PhysicsEngine", "basicphysics");
407 OpenSim.world.Avatar.PhysicsEngineFlying = false;
408 break;
409
410 case "basicphysics":
411 this.m_physicsEngine = "basicphysics";
412 configData.SetAttribute("PhysicsEngine", "basicphysics");
413 OpenSim.world.Avatar.PhysicsEngineFlying = false;
414 break;
415
416 case "RealPhysX":
417 this.m_physicsEngine = "RealPhysX";
418 OpenSim.world.Avatar.PhysicsEngineFlying = true;
419 break;
420
421 case "OpenDynamicsEngine":
422 this.m_physicsEngine = "OpenDynamicsEngine";
423 OpenSim.world.Avatar.PhysicsEngineFlying = true;
424 break;
425 }
426
427 configData.Commit();
428 }
429 catch (Exception e)
430 {
431 Console.WriteLine(e.Message);
432 Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data");
433 Console.WriteLine("Can not continue starting up");
434 Environment.Exit(1);
435 }
436 }
437
438 /// <summary>
439 /// Performs any last-minute sanity checking and shuts down the region server
440 /// </summary>
441 public virtual void Shutdown()
442 {
443 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads");
444 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread");
445 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients");
446 // IMPLEMENT THIS
447 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating");
448 LocalWorld.Close();
449 GridServers.Close();
450 m_console.Close();
451 Environment.Exit(0);
452 }
453
454 /// <summary>
455 /// Performs per-frame updates regularly
456 /// </summary>
457 /// <param name="sender"></param>
458 /// <param name="e"></param>
459 void Heartbeat(object sender, System.EventArgs e)
460 {
461 LocalWorld.Update();
462 }
463
464 #region Console Commands
465 /// <summary>
466 /// Runs commands issued by the server console from the operator
467 /// </summary>
468 /// <param name="command">The first argument of the parameter (the command)</param>
469 /// <param name="cmdparams">Additional arguments passed to the command</param>
470 public void RunCmd(string command, string[] cmdparams)
471 {
472 switch (command)
473 {
474 case "help":
475 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users");
476 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown");
477 break;
478
479 case "show":
480 Show(cmdparams[0]);
481 break;
482
483 case "terrain":
484 string result = "";
485 if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result))
486 {
487 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result);
488 }
489 break;
490
491 case "shutdown":
492 Shutdown();
493 break;
494
495 default:
496 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command");
497 break;
498 }
499 }
500
501 /// <summary>
502 /// Outputs to the console information about the region
503 /// </summary>
504 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
505 public void Show(string ShowWhat)
506 {
507 switch (ShowWhat)
508 {
509 case "uptime":
510 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString());
511 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString());
512 break;
513 case "users":
514 OpenSim.world.Avatar TempAv;
515 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
516 foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
517 {
518 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
519 {
520 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
521 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
522 }
523 }
524 break;
525 }
526 }
527 #endregion
528 }
529
530 */
531}
diff --git a/OpenSim/OpenSim.RegionServer/OpenSimNetworkHandler.cs b/OpenSim/OpenSim.RegionServer/OpenSimNetworkHandler.cs
new file mode 100644
index 0000000..15ee740
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/OpenSimNetworkHandler.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Net;
5using System.Net.Sockets;
6using libsecondlife;
7using OpenSim.Framework.Interfaces;
8
9namespace OpenSim
10{
11 public interface OpenSimNetworkHandler
12 {
13 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
14 void RemoveClientCircuit(uint circuitcode);
15 void RegisterPacketServer(PacketServer server);
16 AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
17 }
18}
diff --git a/OpenSim/OpenSim.RegionServer/PacketServer.cs b/OpenSim/OpenSim.RegionServer/PacketServer.cs
new file mode 100644
index 0000000..9c8f65c
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/PacketServer.cs
@@ -0,0 +1,88 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.world;
5using libsecondlife.Packets;
6
7namespace OpenSim
8{
9 public class PacketServer
10 {
11 private OpenSimNetworkHandler _networkHandler;
12 private World _localWorld;
13 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
14
15 public PacketServer(OpenSimNetworkHandler networkHandler)
16 {
17 _networkHandler = networkHandler;
18 _networkHandler.RegisterPacketServer(this);
19 }
20
21 public World LocalWorld
22 {
23 set
24 {
25 this._localWorld = value;
26 }
27 }
28
29 public virtual void ClientInPacket(uint circuitCode, Packet packet)
30 {
31 if (this.ClientThreads.ContainsKey(circuitCode))
32 {
33 ClientThreads[circuitCode].InPacket(packet);
34 }
35 }
36
37 public virtual bool AddNewCircuitCodeClient(uint circuitCode)
38 {
39 return false;
40 }
41
42 public virtual void SendPacketToAllClients(Packet packet)
43 {
44
45 }
46
47 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
48 {
49
50 }
51
52 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
53 {
54
55 }
56
57 public virtual void RegisterClientPacketHandlers()
58 {
59 if (this._localWorld != null)
60 {
61 ClientView.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
62 }
63 }
64
65 #region Client Packet Handlers
66
67 public bool RequestUUIDName(ClientView simClient, Packet packet)
68 {
69 System.Text.Encoding enc = System.Text.Encoding.ASCII;
70 Console.WriteLine(packet.ToString());
71 UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
72 UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
73 nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
74
75 for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
76 {
77 nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
78 nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
79 nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
80 nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
81 }
82 simClient.OutPacket(nameReply);
83 return true;
84 }
85
86 #endregion
87 }
88}
diff --git a/OpenSim/OpenSim.RegionServer/RegionInfo.cs b/OpenSim/OpenSim.RegionServer/RegionInfo.cs
new file mode 100644
index 0000000..f82495a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/RegionInfo.cs
@@ -0,0 +1,261 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Net;
5using System.Web;
6using System.IO;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Utilities;
9using libsecondlife;
10
11namespace OpenSim
12{
13 public class RegionInfo : RegionInfoBase
14 {
15 //following should be removed and the GenericConfig object passed around,
16 //so each class (AssetServer, GridServer etc) can access what config data they want
17 public string AssetURL = "http://127.0.0.1:8003/";
18 public string AssetSendKey = "";
19
20 public string GridURL = "";
21 public string GridSendKey = "";
22 public string GridRecvKey = "";
23 public string UserURL = "";
24 public string UserSendKey = "";
25 public string UserRecvKey = "";
26 private bool isSandbox;
27
28 public string DataStore;
29
30 public RegionInfo()
31 {
32
33 }
34
35 public void SaveToGrid()
36 {
37 //we really want to keep any server connection code out of here and out of the code code
38 // and put it in the server connection classes (those inheriting from IGridServer etc)
39 string reqtext;
40 reqtext = "<Root>";
41 reqtext += "<authkey>" + this.GridSendKey + "</authkey>";
42 reqtext += "<sim>";
43 reqtext += "<uuid>" + this.SimUUID.ToString() + "</uuid>";
44 reqtext += "<regionname>" + this.RegionName + "</regionname>";
45 reqtext += "<sim_ip>" + this.IPListenAddr + "</sim_ip>";
46 reqtext += "<sim_port>" + this.IPListenPort.ToString() + "</sim_port>";
47 reqtext += "<region_locx>" + this.RegionLocX.ToString() + "</region_locx>";
48 reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>";
49 reqtext += "<estate_id>1</estate_id>";
50 reqtext += "</sim>";
51 reqtext += "</Root>";
52
53 byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext);
54 string newpath = "";
55 if (this.GridURL.EndsWith("/"))
56 {
57 newpath = this.GridURL + "sims/";
58 }
59 else
60 {
61 newpath = this.GridURL + "/sims/";
62 }
63
64 WebRequest GridSaveReq = WebRequest.Create(newpath + this.SimUUID.ToString());
65 GridSaveReq.Method = "POST";
66 GridSaveReq.ContentType = "application/x-www-form-urlencoded";
67 GridSaveReq.ContentLength = reqdata.Length;
68
69 Stream stOut = GridSaveReq.GetRequestStream();
70 stOut.Write(reqdata, 0, reqdata.Length);
71 stOut.Close();
72
73 WebResponse gridresp = GridSaveReq.GetResponse();
74 StreamReader stIn = new StreamReader(gridresp.GetResponseStream(), Encoding.ASCII);
75 string GridResponse = stIn.ReadToEnd();
76 stIn.Close();
77 gridresp.Close();
78
79 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse);
80 }
81
82 public void InitConfig(bool sandboxMode, IGenericConfig configData)
83 {
84 this.isSandbox = sandboxMode;
85 try
86 {
87 // Sim UUID
88 string attri = "";
89 attri = configData.GetAttribute("SimUUID");
90 if (attri == "")
91 {
92 this.SimUUID = LLUUID.Random();
93 configData.SetAttribute("SimUUID", this.SimUUID.ToString());
94 }
95 else
96 {
97 this.SimUUID = new LLUUID(attri);
98 }
99
100 // Sim name
101 attri = "";
102 attri = configData.GetAttribute("SimName");
103 if (attri == "")
104 {
105 this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name", "OpenSim test");
106 configData.SetAttribute("SimName", this.RegionName);
107 }
108 else
109 {
110 this.RegionName = attri;
111 }
112 // Sim/Grid location X
113 attri = "";
114 attri = configData.GetAttribute("SimLocationX");
115 if (attri == "")
116 {
117 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X", "997");
118 configData.SetAttribute("SimLocationX", location);
119 this.RegionLocX = (uint)Convert.ToUInt32(location);
120 }
121 else
122 {
123 this.RegionLocX = (uint)Convert.ToUInt32(attri);
124 }
125 // Sim/Grid location Y
126 attri = "";
127 attri = configData.GetAttribute("SimLocationY");
128 if (attri == "")
129 {
130 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y", "996");
131 configData.SetAttribute("SimLocationY", location);
132 this.RegionLocY = (uint)Convert.ToUInt32(location);
133 }
134 else
135 {
136 this.RegionLocY = (uint)Convert.ToUInt32(attri);
137 }
138
139 // Local storage datastore
140 attri = "";
141 attri = configData.GetAttribute("Datastore");
142 if (attri == "")
143 {
144 string datastore = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Filename for local storage", "localworld.yap");
145 configData.SetAttribute("Datastore", datastore);
146 this.DataStore = datastore;
147 }
148 else
149 {
150 this.DataStore = attri;
151 }
152
153 //Sim Listen Port
154 attri = "";
155 attri = configData.GetAttribute("SimListenPort");
156 if (attri == "")
157 {
158 string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections", "9000");
159 configData.SetAttribute("SimListenPort", port);
160 this.IPListenPort = Convert.ToInt32(port);
161 }
162 else
163 {
164 this.IPListenPort = Convert.ToInt32(attri);
165 }
166 //Sim Listen Address
167 attri = "";
168 attri = configData.GetAttribute("SimListenAddress");
169 if (attri == "")
170 {
171 this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections", "127.0.0.1");
172 configData.SetAttribute("SimListenAddress", this.IPListenAddr);
173 }
174 else
175 {
176 this.IPListenAddr = attri;
177 }
178
179 if (!isSandbox)
180 {
181 //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object
182
183 //Grid Server URL
184 attri = "";
185 attri = configData.GetAttribute("GridServerURL");
186 if (attri == "")
187 {
188 this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL","http://127.0.0.1:8001/");
189 configData.SetAttribute("GridServerURL", this.GridURL);
190 }
191 else
192 {
193 this.GridURL = attri;
194 }
195
196 //Grid Send Key
197 attri = "";
198 attri = configData.GetAttribute("GridSendKey");
199 if (attri == "")
200 {
201 this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server","null");
202 configData.SetAttribute("GridSendKey", this.GridSendKey);
203 }
204 else
205 {
206 this.GridSendKey = attri;
207 }
208
209 //Grid Receive Key
210 attri = "";
211 attri = configData.GetAttribute("GridRecvKey");
212 if (attri == "")
213 {
214 this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server","null");
215 configData.SetAttribute("GridRecvKey", this.GridRecvKey);
216 }
217 else
218 {
219 this.GridRecvKey = attri;
220 }
221
222 attri = "";
223 attri = configData.GetAttribute("AssetServerURL");
224 if (attri == "")
225 {
226 this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/");
227 configData.SetAttribute("AssetServerURL", this.GridURL);
228 }
229 else
230 {
231 this.AssetURL = attri;
232 }
233
234 }
235 this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
236 if (!this.isSandbox)
237 {
238 this.SaveToGrid();
239 }
240 configData.Commit();
241 }
242 catch (Exception e)
243 {
244 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Config.cs:InitConfig() - Exception occured");
245 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
246 }
247
248 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Sim settings loaded:");
249 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "UUID: " + this.SimUUID.ToStringHyphenated());
250 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Name: " + this.RegionName);
251 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
252 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Handle: " + this.RegionHandle.ToString());
253 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
254 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Sandbox Mode? " + isSandbox.ToString());
255 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset URL: " + this.AssetURL);
256 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset key: " + this.AssetSendKey);
257 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid URL: " + this.GridURL);
258 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid key: " + this.GridSendKey);
259 }
260 }
261}
diff --git a/OpenSim/OpenSim.RegionServer/RegionInfoBase.cs b/OpenSim/OpenSim.RegionServer/RegionInfoBase.cs
new file mode 100644
index 0000000..42d3030
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/RegionInfoBase.cs
@@ -0,0 +1,32 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Net;
5using System.Web;
6using System.IO;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Utilities;
9using libsecondlife;
10
11namespace OpenSim
12{
13 public class RegionInfoBase
14 {
15 public LLUUID SimUUID;
16 public string RegionName;
17 public uint RegionLocX;
18 public uint RegionLocY;
19 public ulong RegionHandle;
20 public ushort RegionWaterHeight = 20;
21 public bool RegionTerraform = true;
22
23 public int IPListenPort;
24 public string IPListenAddr;
25
26 public RegionInfoBase()
27 {
28
29 }
30 }
31
32}
diff --git a/OpenSim/OpenSim.RegionServer/RegionServerBase.cs b/OpenSim/OpenSim.RegionServer/RegionServerBase.cs
new file mode 100644
index 0000000..69a8748
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/RegionServerBase.cs
@@ -0,0 +1,103 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13using OpenSim.world;
14using OpenSim.Terrain;
15using OpenSim.Framework.Interfaces;
16using OpenSim.Framework.Types;
17using OpenSim.UserServer;
18using OpenSim.Assets;
19using OpenSim.CAPS;
20using OpenSim.Framework.Console;
21using OpenSim.Physics.Manager;
22using Nwc.XmlRpc;
23using OpenSim.Servers;
24using OpenSim.GenericConfig;
25
26namespace OpenSim
27{
28 public class RegionServerBase
29 {
30 protected IGenericConfig localConfig;
31 protected PhysicsManager physManager;
32 protected Grid GridServers;
33 protected AssetCache AssetCache;
34 protected InventoryCache InventoryCache;
35 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
36 protected DateTime startuptime;
37 protected RegionInfo regionData;
38
39 protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
40 public string m_physicsEngine;
41 public bool m_sandbox = false;
42 public bool m_loginserver;
43 public bool user_accounts = false;
44 public bool gridLocalAsset = false;
45 protected bool configFileSetup = false;
46 public string m_config;
47
48 protected UDPServer m_udpServer;
49 protected BaseHttpServer httpServer;
50 protected AuthenticateSessionsBase AuthenticateSessionsHandler;
51
52 protected ConsoleBase m_console;
53
54 public RegionServerBase()
55 {
56
57 }
58
59 public RegionServerBase(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
60 {
61 this.configFileSetup = useConfigFile;
62 m_sandbox = sandBoxMode;
63 m_loginserver = startLoginServer;
64 m_physicsEngine = physicsEngine;
65 m_config = configFile;
66 }
67
68 protected World m_localWorld;
69 public World LocalWorld
70 {
71 get { return m_localWorld; }
72 }
73
74 /// <summary>
75 /// Performs initialisation of the world, such as loading configuration from disk.
76 /// </summary>
77 public virtual void StartUp()
78 {
79 }
80
81 protected virtual void SetupLocalGridServers()
82 {
83 }
84
85 protected virtual void SetupRemoteGridServers()
86 {
87
88 }
89
90 protected virtual void SetupLocalWorld()
91 {
92 }
93
94 protected virtual void SetupHttpListener()
95 {
96 }
97
98 protected virtual void ConnectToRemoteGridServer()
99 {
100
101 }
102 }
103}
diff --git a/OpenSim/OpenSim.RegionServer/UDPServer.cs b/OpenSim/OpenSim.RegionServer/UDPServer.cs
new file mode 100644
index 0000000..3a93e66
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/UDPServer.cs
@@ -0,0 +1,205 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13using OpenSim.world;
14using OpenSim.Terrain;
15using OpenSim.Framework.Interfaces;
16using OpenSim.Framework.Types;
17using OpenSim.UserServer;
18using OpenSim.Assets;
19using OpenSim.CAPS;
20using OpenSim.Framework.Console;
21using Nwc.XmlRpc;
22using OpenSim.Servers;
23using OpenSim.GenericConfig;
24
25namespace OpenSim
26{
27 public delegate AuthenticateResponse AuthenticateSessionHandler(LLUUID sessionID, LLUUID agentID, uint circuitCode);
28
29 public class UDPServer : OpenSimNetworkHandler
30 {
31 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
32 public Socket Server;
33 protected IPEndPoint ServerIncoming;
34 protected byte[] RecvBuffer = new byte[4096];
35 protected byte[] ZeroBuffer = new byte[8192];
36 protected IPEndPoint ipeSender;
37 protected EndPoint epSender;
38 protected AsyncCallback ReceivedData;
39 protected PacketServer _packetServer;
40
41 protected int listenPort;
42 protected Grid m_gridServers;
43 protected World m_localWorld;
44 protected AssetCache m_assetCache;
45 protected InventoryCache m_inventoryCache;
46 protected RegionInfo m_regionData;
47 protected bool m_sandbox = false;
48 protected bool user_accounts = false;
49 protected ConsoleBase m_console;
50 protected AuthenticateSessionsBase m_authenticateSessionsClass;
51
52 public AuthenticateSessionHandler AuthenticateHandler;
53
54 public PacketServer PacketServer
55 {
56 get
57 {
58 return _packetServer;
59 }
60 set
61 {
62 _packetServer = value;
63 }
64 }
65
66 public World LocalWorld
67 {
68 set
69 {
70 this.m_localWorld = value;
71 this._packetServer.LocalWorld = this.m_localWorld;
72 }
73 }
74
75 public UDPServer()
76 {
77 }
78
79 public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console, AuthenticateSessionsBase authenticateClass)
80 {
81 listenPort = port;
82 this.m_gridServers = gridServers;
83 this.m_assetCache = assetCache;
84 this.m_inventoryCache = inventoryCache;
85 this.m_regionData = _regionData;
86 this.m_sandbox = sandbox;
87 this.user_accounts = accounts;
88 this.m_console = console;
89 this.m_authenticateSessionsClass = authenticateClass;
90 this.CreatePacketServer();
91
92 //set up delegate for authenticate sessions
93 this.AuthenticateHandler = new AuthenticateSessionHandler(this.m_authenticateSessionsClass.AuthenticateSession);
94 }
95
96 protected virtual void CreatePacketServer()
97 {
98 PacketServer packetServer = new PacketServer(this);
99 }
100
101 protected virtual void OnReceivedData(IAsyncResult result)
102 {
103 ipeSender = new IPEndPoint(IPAddress.Any, 0);
104 epSender = (EndPoint)ipeSender;
105 Packet packet = null;
106 int numBytes = Server.EndReceiveFrom(result, ref epSender);
107 int packetEnd = numBytes - 1;
108
109 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
110
111 // do we already have a circuit for this endpoint
112 if (this.clientCircuits.ContainsKey(epSender))
113 {
114 //if so then send packet to the packetserver
115 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
116 }
117 else if (packet.Type == PacketType.UseCircuitCode)
118 {
119 // new client
120 this.AddNewClient(packet);
121 }
122 else
123 { // invalid client
124 Console.Error.WriteLine("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
125 }
126
127 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
128 }
129
130 protected virtual void AddNewClient(Packet packet)
131 {
132 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
133 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
134 bool isChildAgent = false;
135
136 ClientView newuser = new ClientView(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData, m_authenticateSessionsClass);
137 if ((this.m_gridServers.UserServer != null) && (user_accounts))
138 {
139 newuser.UserServer = this.m_gridServers.UserServer;
140 }
141 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
142 this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
143 }
144
145 public void ServerListener()
146 {
147 m_console.WriteLine("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort);
148
149 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
150 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
151 Server.Bind(ServerIncoming);
152
153 m_console.WriteLine("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
154
155 ipeSender = new IPEndPoint(IPAddress.Any, 0);
156 epSender = (EndPoint)ipeSender;
157 ReceivedData = new AsyncCallback(this.OnReceivedData);
158 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
159
160 m_console.WriteLine("UDPServer.cs:ServerListener() - Listening...");
161
162 }
163
164 public virtual void RegisterPacketServer(PacketServer server)
165 {
166 this._packetServer = server;
167 }
168
169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
170 {
171 // find the endpoint for this circuit
172 EndPoint sendto = null;
173 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
174 {
175 if (p.Value == circuitcode)
176 {
177 sendto = p.Key;
178 break;
179 }
180 }
181 if (sendto != null)
182 {
183 //we found the endpoint so send the packet to it
184 this.Server.SendTo(buffer, size, flags, sendto);
185 }
186 }
187
188 public virtual void RemoveClientCircuit(uint circuitcode)
189 {
190 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
191 {
192 if (p.Value == circuitcode)
193 {
194 this.clientCircuits.Remove(p.Key);
195 break;
196 }
197 }
198 }
199
200 public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
201 {
202 return this.AuthenticateHandler(sessionID, agentID, circuitCode);
203 }
204 }
205} \ No newline at end of file
diff --git a/OpenSim/OpenSim.RegionServer/VersionInfo.cs b/OpenSim/OpenSim.RegionServer/VersionInfo.cs
new file mode 100644
index 0000000..49cc6a5
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/VersionInfo.cs
@@ -0,0 +1,37 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*/
26
27using System;
28
29namespace OpenSim
30{
31 /// <summary>
32 /// </summary>
33 public class VersionInfo
34 {
35 public static string Version = "0.2, SVN build - please use releng if you desire any form of support";
36 }
37}
diff --git a/OpenSim/OpenSim.RegionServer/types/Mesh.cs b/OpenSim/OpenSim.RegionServer/types/Mesh.cs
new file mode 100644
index 0000000..3e00c91
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/types/Mesh.cs
@@ -0,0 +1,28 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.types
6{
7 // TODO: This will need some performance tuning no doubt.
8 public class Mesh
9 {
10 public List<Triangle> mesh;
11
12 public Mesh()
13 {
14 mesh = new List<Triangle>();
15 }
16
17 public void AddTri(Triangle tri)
18 {
19 mesh.Add(tri);
20 }
21
22 public static Mesh operator +(Mesh a, Mesh b)
23 {
24 a.mesh.AddRange(b.mesh);
25 return a;
26 }
27 }
28}
diff --git a/OpenSim/OpenSim.RegionServer/types/Triangle.cs b/OpenSim/OpenSim.RegionServer/types/Triangle.cs
new file mode 100644
index 0000000..8dfea6e
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/types/Triangle.cs
@@ -0,0 +1,28 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Axiom.MathLib;
5
6namespace OpenSim.types
7{
8 public class Triangle
9 {
10 Vector3 a;
11 Vector3 b;
12 Vector3 c;
13
14 public Triangle()
15 {
16 a = new Vector3();
17 b = new Vector3();
18 c = new Vector3();
19 }
20
21 public Triangle(Vector3 A, Vector3 B, Vector3 C)
22 {
23 a = A;
24 b = B;
25 c = C;
26 }
27 }
28}
diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.Client.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.Client.cs
new file mode 100644
index 0000000..7656a89
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Avatar.Client.cs
@@ -0,0 +1,33 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife.Packets;
5
6namespace OpenSim.world
7{
8 partial class Avatar
9 {
10 private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> updateList = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
11 private List<Entity> interestList = new List<Entity>();
12
13 public void SendPacketToViewer(Packet packet)
14 {
15 this.ControllingClient.OutPacket(packet);
16 }
17
18 public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock)
19 {
20
21 }
22
23 public void SendUpdateListToViewer()
24 {
25
26 }
27
28 private void UpdateInterestList()
29 {
30
31 }
32 }
33}
diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs
new file mode 100644
index 0000000..67eab24
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs
@@ -0,0 +1,338 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Physics.Manager;
7
8namespace OpenSim.world
9{
10 partial class Avatar
11 {
12 public override void update()
13 {
14 if (!this.childAvatar)
15 {
16 if (this._physActor == null)
17 {
18 //HACKHACK: Note to work out why this entity does not have a physics actor
19 // and prehaps create one.
20 return;
21 }
22 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
23 if (this.updateflag)
24 {
25 //need to send movement info
26 //so create the improvedterseobjectupdate packet
27 //use CreateTerseBlock()
28 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
29 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
30 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
31 terse.RegionData.TimeDilation = 64096;
32 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
33 terse.ObjectData[0] = terseBlock;
34 List<Avatar> avList = this.m_world.RequestAvatarList();
35 foreach (Avatar client in avList)
36 {
37 client.SendPacketToViewer(terse);
38 }
39
40 updateflag = false;
41 //this._updateCount = 0;
42 }
43 else
44 {
45
46 if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
47 {
48 _updateCount++;
49 if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
50 {
51 //It has been a while since last update was sent so lets send one.
52 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
53 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
54 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
55 terse.RegionData.TimeDilation = 64096;
56 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
57 terse.ObjectData[0] = terseBlock;
58 List<Avatar> avList = this.m_world.RequestAvatarList();
59 foreach (Avatar client in avList)
60 {
61 client.SendPacketToViewer(terse);
62 }
63 _updateCount = 0;
64 }
65
66 if (this.movementflag == 16)
67 {
68 movementflag = 0;
69 }
70 }
71
72 }
73 this.positionLastFrame = pos2;
74
75 if (!this.ControllingClient.m_sandboxMode)
76 {
77 if (pos2.X < 0)
78 {
79 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
80 }
81
82 if (pos2.Y < 0)
83 {
84 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
85 }
86
87 if (pos2.X > 255)
88 {
89 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
90 }
91
92 if (pos2.Y > 255)
93 {
94 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z));
95 }
96 }
97 }
98
99 }
100
101 public void SendUpdateToOtherClient(Avatar remoteAvatar)
102 {
103 ObjectUpdatePacket objupdate = CreateUpdatePacket();
104 remoteAvatar.SendPacketToViewer(objupdate);
105 }
106
107 public ObjectUpdatePacket CreateUpdatePacket()
108 {
109 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
110 //send a objectupdate packet with information about the clients avatar
111 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
112 objupdate.RegionData.RegionHandle = m_regionHandle;
113 objupdate.RegionData.TimeDilation = 64096;
114 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
115
116 objupdate.ObjectData[0] = AvatarTemplate;
117 //give this avatar object a local id and assign the user a name
118 objupdate.ObjectData[0].ID = this.localid;
119 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
120 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
121
122 libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
123
124 byte[] pb = pos2.GetBytes();
125
126 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
127 return objupdate;
128 }
129
130 public void SendInitialPosition()
131 {
132 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
133 //send a objectupdate packet with information about the clients avatar
134
135 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
136 objupdate.RegionData.RegionHandle = m_regionHandle;
137 objupdate.RegionData.TimeDilation = 64096;
138 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
139 objupdate.ObjectData[0] = AvatarTemplate;
140 //give this avatar object a local id and assign the user a name
141
142 objupdate.ObjectData[0].ID = this.localid;
143 this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
144 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
145 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
146 byte[] pb = pos2.GetBytes();
147 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
148 m_world._localNumber++;
149
150 List<Avatar> avList = this.m_world.RequestAvatarList();
151 foreach (Avatar client in avList)
152 {
153 client.SendPacketToViewer(objupdate);
154 if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
155 {
156 SendAppearanceToOtherAgent(client);
157 }
158 }
159 }
160
161 public void SendOurAppearance()
162 {
163 ControllingClient.SendAppearance(this.Wearables);
164 }
165
166 public void SendOurAppearance(ClientView OurClient)
167 {
168 //event handler for wearables request
169 this.SendOurAppearance();
170 }
171
172 public void SendAppearanceToOtherAgent(Avatar avatarInfo)
173 {
174 AvatarAppearancePacket avp = new AvatarAppearancePacket();
175 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
176 avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
177
178 AvatarAppearancePacket.VisualParamBlock avblock = null;
179 for (int i = 0; i < 218; i++)
180 {
181 avblock = new AvatarAppearancePacket.VisualParamBlock();
182 avblock.ParamValue = visualParams[i];
183 avp.VisualParam[i] = avblock;
184 }
185
186 avp.Sender.IsTrial = false;
187 avp.Sender.ID = ControllingClient.AgentID;
188 avatarInfo.SendPacketToViewer(avp);
189 }
190
191 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
192 {
193 LLObject.TextureEntry tex = new LLObject.TextureEntry(texture, 0, texture.Length);
194 this.avatarAppearanceTexture = tex;
195
196 for (int i = 0; i < visualParam.Length; i++)
197 {
198 this.visualParams[i] = visualParam[i].ParamValue;
199 }
200
201 List<Avatar> avList = this.m_world.RequestAvatarList();
202 foreach (Avatar client in avList)
203 {
204 if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
205 {
206 SendAppearanceToOtherAgent(client);
207 }
208 }
209 }
210
211 public void StopMovement()
212 {
213 this._physActor.Velocity = new PhysicsVector(0, 0, 0);
214 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
215 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
216 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
217 terse.RegionData.TimeDilation = 64096;
218 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
219 terse.ObjectData[0] = terseBlock;
220 List<Avatar> avList = this.m_world.RequestAvatarList();
221 foreach (Avatar client in avList)
222 {
223 client.SendPacketToViewer(terse);
224 }
225 }
226
227 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
228 {
229 byte[] bytes = new byte[60];
230 int i = 0;
231 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
232
233 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
234 libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
235 lock (m_world.LockPhysicsEngine)
236 {
237 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
238 }
239
240 uint ID = this.localid;
241
242 bytes[i++] = (byte)(ID % 256);
243 bytes[i++] = (byte)((ID >> 8) % 256);
244 bytes[i++] = (byte)((ID >> 16) % 256);
245 bytes[i++] = (byte)((ID >> 24) % 256);
246 bytes[i++] = 0;
247 bytes[i++] = 1;
248 i += 14;
249 bytes[i++] = 128;
250 bytes[i++] = 63;
251
252 byte[] pb = pos2.GetBytes();
253 Array.Copy(pb, 0, bytes, i, pb.Length);
254 i += 12;
255 ushort InternVelocityX;
256 ushort InternVelocityY;
257 ushort InternVelocityZ;
258 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
259 lock (m_world.LockPhysicsEngine)
260 {
261 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
262 }
263 internDirec = internDirec / 128.0f;
264 internDirec.x += 1;
265 internDirec.y += 1;
266 internDirec.z += 1;
267
268 InternVelocityX = (ushort)(32768 * internDirec.x);
269 InternVelocityY = (ushort)(32768 * internDirec.y);
270 InternVelocityZ = (ushort)(32768 * internDirec.z);
271
272 ushort ac = 32767;
273 bytes[i++] = (byte)(InternVelocityX % 256);
274 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
275 bytes[i++] = (byte)(InternVelocityY % 256);
276 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
277 bytes[i++] = (byte)(InternVelocityZ % 256);
278 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
279
280 //accel
281 bytes[i++] = (byte)(ac % 256);
282 bytes[i++] = (byte)((ac >> 8) % 256);
283 bytes[i++] = (byte)(ac % 256);
284 bytes[i++] = (byte)((ac >> 8) % 256);
285 bytes[i++] = (byte)(ac % 256);
286 bytes[i++] = (byte)((ac >> 8) % 256);
287
288 //rot
289 bytes[i++] = (byte)(ac % 256);
290 bytes[i++] = (byte)((ac >> 8) % 256);
291 bytes[i++] = (byte)(ac % 256);
292 bytes[i++] = (byte)((ac >> 8) % 256);
293 bytes[i++] = (byte)(ac % 256);
294 bytes[i++] = (byte)((ac >> 8) % 256);
295 bytes[i++] = (byte)(ac % 256);
296 bytes[i++] = (byte)((ac >> 8) % 256);
297
298 //rotation vel
299 bytes[i++] = (byte)(ac % 256);
300 bytes[i++] = (byte)((ac >> 8) % 256);
301 bytes[i++] = (byte)(ac % 256);
302 bytes[i++] = (byte)((ac >> 8) % 256);
303 bytes[i++] = (byte)(ac % 256);
304 bytes[i++] = (byte)((ac >> 8) % 256);
305
306 dat.Data = bytes;
307 return (dat);
308 }
309
310 // Sends animation update
311 public void SendAnimPack(LLUUID animID, int seq)
312 {
313 AvatarAnimationPacket ani = new AvatarAnimationPacket();
314 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
315 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
316 ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
317 ani.Sender = new AvatarAnimationPacket.SenderBlock();
318 ani.Sender.ID = ControllingClient.AgentID;
319 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
320 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
321 ani.AnimationList[0].AnimID = this.current_anim = animID;
322 ani.AnimationList[0].AnimSequenceID = this.anim_seq = seq;
323
324 List<Avatar> avList = this.m_world.RequestAvatarList();
325 foreach (Avatar client in avList)
326 {
327 client.SendPacketToViewer(ani);
328 }
329
330 }
331
332 public void SendAnimPack()
333 {
334 this.SendAnimPack(this.current_anim, this.anim_seq);
335 }
336
337 }
338}
diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.cs
new file mode 100644
index 0000000..9401036
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Avatar.cs
@@ -0,0 +1,438 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Physics.Manager;
8using OpenSim.Framework.Inventory;
9using OpenSim.Framework.Interfaces;
10using Axiom.MathLib;
11
12namespace OpenSim.world
13{
14 public partial class Avatar : Entity
15 {
16 public static bool PhysicsEngineFlying = false;
17 public static AvatarAnimations Animations;
18 public string firstname;
19 public string lastname;
20 public ClientView ControllingClient;
21 public LLUUID current_anim;
22 public int anim_seq;
23 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
24 private bool updateflag = false;
25 private byte movementflag = 0;
26 private List<NewForce> forcesList = new List<NewForce>();
27 private short _updateCount = 0;
28 private Axiom.MathLib.Quaternion bodyRot;
29 private LLObject.TextureEntry avatarAppearanceTexture = null;
30 private byte[] visualParams;
31 private AvatarWearable[] Wearables;
32 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
33 private ulong m_regionHandle;
34 //private Dictionary<uint, ClientView> m_clientThreads;
35 private string m_regionName;
36 private ushort m_regionWaterHeight;
37 private bool m_regionTerraform;
38 private bool childAvatar = false;
39
40 public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
41 {
42 m_world = world;
43 // m_clientThreads = clientThreads;
44 m_regionName = regionName;
45 m_regionHandle = regionHandle;
46 m_regionTerraform = regionTerraform;
47 m_regionWaterHeight = regionWater;
48
49 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Avatar.cs - Loading details from grid (DUMMY)");
50 ControllingClient = TheClient;
51 localid = 8880000 + (this.m_world._localNumber++);
52 Pos = ControllingClient.startpos;
53 visualParams = new byte[218];
54 for (int i = 0; i < 218; i++)
55 {
56 visualParams[i] = 100;
57 }
58 Wearables = new AvatarWearable[13]; //should be 13 of these
59 for (int i = 0; i < 13; i++)
60 {
61 Wearables[i] = new AvatarWearable();
62 }
63 this.Wearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
64 this.Wearables[0].ItemID = LLUUID.Random();
65
66 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
67
68 //register for events
69 ControllingClient.OnRequestWearables += new ClientView.GenericCall(this.SendOurAppearance);
70 ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
71 ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.CompleteMovement);
72 ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.SendInitialPosition);
73 ControllingClient.OnAgentUpdate += new ClientView.GenericCall3(this.HandleAgentUpdate);
74 ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
75 ControllingClient.OnChildAgentStatus += new ClientView.StatusChange(this.ChildStatusChange);
76 ControllingClient.OnStopMovement += new ClientView.GenericCall2(this.StopMovement);
77 }
78
79 public PhysicsActor PhysActor
80 {
81 set
82 {
83 this._physActor = value;
84 }
85 get
86 {
87 return _physActor;
88 }
89 }
90
91 public void ChildStatusChange(bool status)
92 {
93 Console.WriteLine("child agent status change");
94 this.childAvatar = status;
95
96 if (this.childAvatar == true)
97 {
98 this.StopMovement();
99 }
100 else
101 {
102 LLVector3 startp = ControllingClient.StartPos;
103 lock (m_world.LockPhysicsEngine)
104 {
105 this._physActor.Position = new PhysicsVector(startp.X, startp.Y, startp.Z);
106 }
107 }
108 }
109
110 public override void addForces()
111 {
112 lock (this.forcesList)
113 {
114 if (this.forcesList.Count > 0)
115 {
116 for (int i = 0; i < this.forcesList.Count; i++)
117 {
118 NewForce force = this.forcesList[i];
119 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
120 lock (m_world.LockPhysicsEngine)
121 {
122 this._physActor.Velocity = phyVector;
123 }
124 this.updateflag = true;
125 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
126 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
127 }
128 for (int i = 0; i < this.forcesList.Count; i++)
129 {
130 this.forcesList.RemoveAt(0);
131 }
132 }
133 }
134 }
135
136 public static void SetupTemplate(string name)
137 {
138 FileInfo fInfo = new FileInfo(name);
139 long numBytes = fInfo.Length;
140 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
141 BinaryReader br = new BinaryReader(fStream);
142 byte[] data1 = br.ReadBytes((int)numBytes);
143 br.Close();
144 fStream.Close();
145
146 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
147
148 SetDefaultPacketValues(objdata);
149 objdata.TextureEntry = data1;
150 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
151 objdata.PathCurve = 16;
152 objdata.ProfileCurve = 1;
153 objdata.PathScaleX = 100;
154 objdata.PathScaleY = 100;
155 objdata.ParentID = 0;
156 objdata.OwnerID = LLUUID.Zero;
157 objdata.Scale = new LLVector3(1, 1, 1);
158 objdata.PCode = 47;
159 System.Text.Encoding enc = System.Text.Encoding.ASCII;
160 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
161 pos.X = 100f;
162 objdata.ID = 8880000;
163 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
164 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
165 //objdata.FullID=user.AgentID;
166 byte[] pb = pos.GetBytes();
167 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
168
169 Avatar.AvatarTemplate = objdata;
170 }
171
172 protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
173 {
174 objdata.PSBlock = new byte[0];
175 objdata.ExtraParams = new byte[1];
176 objdata.MediaURL = new byte[0];
177 objdata.NameValue = new byte[0];
178 objdata.Text = new byte[0];
179 objdata.TextColor = new byte[4];
180 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
181 objdata.JointPivot = new LLVector3(0, 0, 0);
182 objdata.Material = 4;
183 objdata.TextureAnim = new byte[0];
184 objdata.Sound = LLUUID.Zero;
185 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
186 objdata.TextureEntry = ntex.ToBytes();
187 objdata.State = 0;
188 objdata.Data = new byte[0];
189
190 objdata.ObjectData = new byte[76];
191 objdata.ObjectData[15] = 128;
192 objdata.ObjectData[16] = 63;
193 objdata.ObjectData[56] = 128;
194 objdata.ObjectData[61] = 102;
195 objdata.ObjectData[62] = 40;
196 objdata.ObjectData[63] = 61;
197 objdata.ObjectData[64] = 189;
198
199
200 }
201
202 public void CompleteMovement()
203 {
204 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
205 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
206 mov.AgentData.SessionID = this.ControllingClient.SessionID;
207 mov.AgentData.AgentID = this.ControllingClient.AgentID;
208 mov.Data.RegionHandle = this.m_regionHandle;
209 // TODO - dynamicalise this stuff
210 mov.Data.Timestamp = 1172750370;
211 mov.Data.Position = this.ControllingClient.startpos;
212 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
213
214 ControllingClient.OutPacket(mov);
215 }
216
217 public void HandleAgentUpdate(Packet pack)
218 {
219 this.HandleUpdate((AgentUpdatePacket)pack);
220 }
221
222 public void HandleUpdate(AgentUpdatePacket pack)
223 {
224 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0)
225 {
226 if (this._physActor.Flying == false)
227 {
228 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"];
229 this.anim_seq = 1;
230 this.SendAnimPack();
231 }
232 this._physActor.Flying = true;
233
234 }
235 else
236 {
237 if (this._physActor.Flying == true)
238 {
239 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
240 this.anim_seq = 1;
241 this.SendAnimPack();
242 }
243 this._physActor.Flying = false;
244 }
245 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
246 {
247 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
248 if (((movementflag & 1) == 0) || (q != this.bodyRot))
249 {
250
251 if (((movementflag & 1) == 0) && (!this._physActor.Flying))
252 {
253 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"];
254 this.anim_seq = 1;
255 this.SendAnimPack();
256 }
257
258
259 //we should add a new force to the list
260 // but for now we will deal with velocities
261 NewForce newVelocity = new NewForce();
262 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
263 Axiom.MathLib.Vector3 direc = q * v3;
264 direc.Normalize();
265
266 //work out velocity for sim physics system
267 direc = direc * ((0.03f) * 128f);
268 if (this._physActor.Flying)
269 direc *= 4;
270
271 newVelocity.X = direc.x;
272 newVelocity.Y = direc.y;
273 newVelocity.Z = direc.z;
274 this.forcesList.Add(newVelocity);
275 movementflag = 1;
276 this.bodyRot = q;
277 }
278 }
279 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying))
280 {
281 if (((movementflag & 2) == 0) && this._physActor.Flying)
282 {
283 //we should add a new force to the list
284 // but for now we will deal with velocities
285 NewForce newVelocity = new NewForce();
286 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
287 Axiom.MathLib.Vector3 direc = v3;
288 direc.Normalize();
289
290 //work out velocity for sim physics system
291 direc = direc * ((0.03f) * 128f * 2);
292 newVelocity.X = direc.x;
293 newVelocity.Y = direc.y;
294 newVelocity.Z = direc.z;
295 this.forcesList.Add(newVelocity);
296 movementflag = 2;
297 }
298 }
299 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying))
300 {
301 if (((movementflag & 4) == 0) && this._physActor.Flying)
302 {
303 //we should add a new force to the list
304 // but for now we will deal with velocities
305 NewForce newVelocity = new NewForce();
306 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
307 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
308 Axiom.MathLib.Vector3 direc = v3;
309 direc.Normalize();
310
311 //work out velocity for sim physics system
312 direc = direc * ((0.03f) * 128f * 2);
313 newVelocity.X = direc.x;
314 newVelocity.Y = direc.y;
315 newVelocity.Z = direc.z;
316 this.forcesList.Add(newVelocity);
317 movementflag = 4;
318 }
319 }
320 else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
321 {
322 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
323 if (((movementflag & 8) == 0) || (q != this.bodyRot))
324 {
325 //we should add a new force to the list
326 // but for now we will deal with velocities
327 NewForce newVelocity = new NewForce();
328 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
329 Axiom.MathLib.Vector3 direc = q * v3;
330 direc.Normalize();
331
332 //work out velocity for sim physics system
333 direc = direc * ((0.03f) * 128f);
334 if (this._physActor.Flying)
335 direc *= 2;
336
337 newVelocity.X = direc.x;
338 newVelocity.Y = direc.y;
339 newVelocity.Z = direc.z;
340 this.forcesList.Add(newVelocity);
341 movementflag = 8;
342 this.bodyRot = q;
343 }
344 }
345 else
346 {
347 if (movementflag == 16)
348 {
349 movementflag = 0;
350 }
351 if ((movementflag) != 0)
352 {
353 NewForce newVelocity = new NewForce();
354 newVelocity.X = 0;
355 newVelocity.Y = 0;
356 newVelocity.Z = 0;
357 this.forcesList.Add(newVelocity);
358 movementflag = 0;
359 // We're standing still, so make it show!
360 if (this._physActor.Flying == false)
361 {
362 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
363 this.anim_seq = 1;
364 this.SendAnimPack();
365 }
366 this.movementflag = 16;
367
368 }
369 }
370 }
371
372 //really really should be moved somewhere else (RegionInfo.cs ?)
373 public void SendRegionHandshake(World regionInfo)
374 {
375 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
376 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
377 RegionHandshakePacket handshake = new RegionHandshakePacket();
378
379 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
380 handshake.RegionInfo.BillableFactor = 0;
381 handshake.RegionInfo.IsEstateManager = false;
382 handshake.RegionInfo.TerrainHeightRange00 = 60;
383 handshake.RegionInfo.TerrainHeightRange01 = 60;
384 handshake.RegionInfo.TerrainHeightRange10 = 60;
385 handshake.RegionInfo.TerrainHeightRange11 = 60;
386 handshake.RegionInfo.TerrainStartHeight00 = 10;
387 handshake.RegionInfo.TerrainStartHeight01 = 10;
388 handshake.RegionInfo.TerrainStartHeight10 = 10;
389 handshake.RegionInfo.TerrainStartHeight11 = 10;
390 handshake.RegionInfo.SimAccess = 13;
391 handshake.RegionInfo.WaterHeight = m_regionWaterHeight;
392 uint regionFlags = 72458694;
393 if (this.m_regionTerraform)
394 {
395 regionFlags -= 64;
396 }
397 handshake.RegionInfo.RegionFlags = regionFlags;
398 handshake.RegionInfo.SimName = _enc.GetBytes(m_regionName + "\0");
399 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
400 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
401 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
402 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
403 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
404 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
405 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
406 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
407 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
408 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
409
410 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
411 this.ControllingClient.OutPacket(handshake);
412 }
413
414 public static void LoadAnims()
415 {
416 Avatar.Animations = new AvatarAnimations();
417 Avatar.Animations.LoadAnims();
418 }
419
420 public override void LandRenegerated()
421 {
422 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 50.0f);
423 }
424 }
425
426 public class NewForce
427 {
428 public float X;
429 public float Y;
430 public float Z;
431
432 public NewForce()
433 {
434
435 }
436 }
437
438}
diff --git a/OpenSim/OpenSim.RegionServer/world/AvatarAnimations.cs b/OpenSim/OpenSim.RegionServer/world/AvatarAnimations.cs
new file mode 100644
index 0000000..b554af8
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/AvatarAnimations.cs
@@ -0,0 +1,163 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.world
7{
8 public class AvatarAnimations
9 {
10
11 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
12 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
13
14 public AvatarAnimations()
15 {
16 }
17
18 public void LoadAnims()
19 {
20 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Avatar.cs:LoadAnims() - Loading avatar animations");
21 AnimsLLUUID.Add("ANIM_AGENT_AFRAID", new LLUUID("6b61c8e8-4747-0d75-12d7-e49ff207a4ca"));
22 AnimsLLUUID.Add("ANIM_AGENT_AIM_BAZOOKA_R", new LLUUID("b5b4a67d-0aee-30d2-72cd-77b333e932ef"));
23 AnimsLLUUID.Add("ANIM_AGENT_AIM_BOW_L", new LLUUID("46bb4359-de38-4ed8-6a22-f1f52fe8f506"));
24 AnimsLLUUID.Add("ANIM_AGENT_AIM_HANDGUN_R", new LLUUID("3147d815-6338-b932-f011-16b56d9ac18b"));
25 AnimsLLUUID.Add("ANIM_AGENT_AIM_RIFLE_R", new LLUUID("ea633413-8006-180a-c3ba-96dd1d756720"));
26 AnimsLLUUID.Add("ANIM_AGENT_ANGRY", new LLUUID("5747a48e-073e-c331-f6f3-7c2149613d3e"));
27 AnimsLLUUID.Add("ANIM_AGENT_AWAY", new LLUUID("fd037134-85d4-f241-72c6-4f42164fedee"));
28 AnimsLLUUID.Add("ANIM_AGENT_BACKFLIP", new LLUUID("c4ca6188-9127-4f31-0158-23c4e2f93304"));
29 AnimsLLUUID.Add("ANIM_AGENT_BELLY_LAUGH", new LLUUID("18b3a4b5-b463-bd48-e4b6-71eaac76c515"));
30 AnimsLLUUID.Add("ANIM_AGENT_BLOW_KISS", new LLUUID("db84829b-462c-ee83-1e27-9bbee66bd624"));
31 AnimsLLUUID.Add("ANIM_AGENT_BORED", new LLUUID("b906c4ba-703b-1940-32a3-0c7f7d791510"));
32 AnimsLLUUID.Add("ANIM_AGENT_BOW", new LLUUID("82e99230-c906-1403-4d9c-3889dd98daba"));
33 AnimsLLUUID.Add("ANIM_AGENT_BRUSH", new LLUUID("349a3801-54f9-bf2c-3bd0-1ac89772af01"));
34 AnimsLLUUID.Add("ANIM_AGENT_BUSY", new LLUUID("efcf670c-2d18-8128-973a-034ebc806b67"));
35 AnimsLLUUID.Add("ANIM_AGENT_CLAP", new LLUUID("9b0c1c4e-8ac7-7969-1494-28c874c4f668"));
36 AnimsLLUUID.Add("ANIM_AGENT_COURTBOW", new LLUUID("9ba1c942-08be-e43a-fb29-16ad440efc50"));
37 AnimsLLUUID.Add("ANIM_AGENT_CROUCH", new LLUUID("201f3fdf-cb1f-dbec-201f-7333e328ae7c"));
38 AnimsLLUUID.Add("ANIM_AGENT_CROUCHWALK", new LLUUID("47f5f6fb-22e5-ae44-f871-73aaaf4a6022"));
39 AnimsLLUUID.Add("ANIM_AGENT_CRY", new LLUUID("92624d3e-1068-f1aa-a5ec-8244585193ed"));
40 AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE", new LLUUID("038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53"));
41 AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE_DONE", new LLUUID("6883a61a-b27b-5914-a61e-dda118a9ee2c"));
42 AnimsLLUUID.Add("ANIM_AGENT_DANCE1", new LLUUID("b68a3d7c-de9e-fc87-eec8-543d787e5b0d"));
43 AnimsLLUUID.Add("ANIM_AGENT_DANCE2", new LLUUID("928cae18-e31d-76fd-9cc9-2f55160ff818"));
44 AnimsLLUUID.Add("ANIM_AGENT_DANCE3", new LLUUID("30047778-10ea-1af7-6881-4db7a3a5a114"));
45 AnimsLLUUID.Add("ANIM_AGENT_DANCE4", new LLUUID("951469f4-c7b2-c818-9dee-ad7eea8c30b7"));
46 AnimsLLUUID.Add("ANIM_AGENT_DANCE5", new LLUUID("4bd69a1d-1114-a0b4-625f-84e0a5237155"));
47 AnimsLLUUID.Add("ANIM_AGENT_DANCE6", new LLUUID("cd28b69b-9c95-bb78-3f94-8d605ff1bb12"));
48 AnimsLLUUID.Add("ANIM_AGENT_DANCE7", new LLUUID("a54d8ee2-28bb-80a9-7f0c-7afbbe24a5d6"));
49 AnimsLLUUID.Add("ANIM_AGENT_DANCE8", new LLUUID("b0dc417c-1f11-af36-2e80-7e7489fa7cdc"));
50 AnimsLLUUID.Add("ANIM_AGENT_DEAD", new LLUUID("57abaae6-1d17-7b1b-5f98-6d11a6411276"));
51 AnimsLLUUID.Add("ANIM_AGENT_DRINK", new LLUUID("0f86e355-dd31-a61c-fdb0-3a96b9aad05f"));
52 AnimsLLUUID.Add("ANIM_AGENT_EMBARRASSED", new LLUUID("514af488-9051-044a-b3fc-d4dbf76377c6"));
53 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_AFRAID", new LLUUID("aa2df84d-cf8f-7218-527b-424a52de766e"));
54 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_ANGER", new LLUUID("1a03b575-9634-b62a-5767-3a679e81f4de"));
55 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_BORED", new LLUUID("214aa6c1-ba6a-4578-f27c-ce7688f61d0d"));
56 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_CRY", new LLUUID("d535471b-85bf-3b4d-a542-93bea4f59d33"));
57 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_DISDAIN", new LLUUID("d4416ff1-09d3-300f-4183-1b68a19b9fc1"));
58 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_EMBARRASSED", new LLUUID("0b8c8211-d78c-33e8-fa28-c51a9594e424"));
59 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_FROWN", new LLUUID("fee3df48-fa3d-1015-1e26-a205810e3001"));
60 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_KISS", new LLUUID("1e8d90cc-a84e-e135-884c-7c82c8b03a14"));
61 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_LAUGH", new LLUUID("62570842-0950-96f8-341c-809e65110823"));
62 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_OPEN_MOUTH", new LLUUID("d63bc1f9-fc81-9625-a0c6-007176d82eb7"));
63 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_REPULSED", new LLUUID("f76cda94-41d4-a229-2872-e0296e58afe1"));
64 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SAD", new LLUUID("eb6ebfb2-a4b3-a19c-d388-4dd5c03823f7"));
65 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SHRUG", new LLUUID("a351b1bc-cc94-aac2-7bea-a7e6ebad15ef"));
66 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SMILE", new LLUUID("b7c7c833-e3d3-c4e3-9fc0-131237446312"));
67 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SURPRISE", new LLUUID("728646d9-cc79-08b2-32d6-937f0a835c24"));
68 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TONGUE_OUT", new LLUUID("835965c6-7f2f-bda2-5deb-2478737f91bf"));
69 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TOOTHSMILE", new LLUUID("b92ec1a5-e7ce-a76b-2b05-bcdb9311417e"));
70 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WINK", new LLUUID("da020525-4d94-59d6-23d7-81fdebf33148"));
71 AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WORRY", new LLUUID("9c05e5c7-6f07-6ca4-ed5a-b230390c3950"));
72 AnimsLLUUID.Add("ANIM_AGENT_FALLDOWN", new LLUUID("666307d9-a860-572d-6fd4-c3ab8865c094"));
73 AnimsLLUUID.Add("ANIM_AGENT_FEMALE_WALK", new LLUUID("f5fc7433-043d-e819-8298-f519a119b688"));
74 AnimsLLUUID.Add("ANIM_AGENT_FINGER_WAG", new LLUUID("c1bc7f36-3ba0-d844-f93c-93be945d644f"));
75 AnimsLLUUID.Add("ANIM_AGENT_FIST_PUMP", new LLUUID("7db00ccd-f380-f3ee-439d-61968ec69c8a"));
76 AnimsLLUUID.Add("ANIM_AGENT_FLY", new LLUUID("aec4610c-757f-bc4e-c092-c6e9caf18daf"));
77 AnimsLLUUID.Add("ANIM_AGENT_FLYSLOW", new LLUUID("2b5a38b2-5e00-3a97-a495-4c826bc443e6"));
78 AnimsLLUUID.Add("ANIM_AGENT_HELLO", new LLUUID("9b29cd61-c45b-5689-ded2-91756b8d76a9"));
79 AnimsLLUUID.Add("ANIM_AGENT_HOLD_BAZOOKA_R", new LLUUID("ef62d355-c815-4816-2474-b1acc21094a6"));
80 AnimsLLUUID.Add("ANIM_AGENT_HOLD_BOW_L", new LLUUID("8b102617-bcba-037b-86c1-b76219f90c88"));
81 AnimsLLUUID.Add("ANIM_AGENT_HOLD_HANDGUN_R", new LLUUID("efdc1727-8b8a-c800-4077-975fc27ee2f2"));
82 AnimsLLUUID.Add("ANIM_AGENT_HOLD_RIFLE_R", new LLUUID("3d94bad0-c55b-7dcc-8763-033c59405d33"));
83 AnimsLLUUID.Add("ANIM_AGENT_HOLD_THROW_R", new LLUUID("7570c7b5-1f22-56dd-56ef-a9168241bbb6"));
84 AnimsLLUUID.Add("ANIM_AGENT_HOVER", new LLUUID("4ae8016b-31b9-03bb-c401-b1ea941db41d"));
85 AnimsLLUUID.Add("ANIM_AGENT_HOVER_DOWN", new LLUUID("20f063ea-8306-2562-0b07-5c853b37b31e"));
86 AnimsLLUUID.Add("ANIM_AGENT_HOVER_UP", new LLUUID("62c5de58-cb33-5743-3d07-9e4cd4352864"));
87 AnimsLLUUID.Add("ANIM_AGENT_IMPATIENT", new LLUUID("5ea3991f-c293-392e-6860-91dfa01278a3"));
88 AnimsLLUUID.Add("ANIM_AGENT_JUMP", new LLUUID("2305bd75-1ca9-b03b-1faa-b176b8a8c49e"));
89 AnimsLLUUID.Add("ANIM_AGENT_JUMP_FOR_JOY", new LLUUID("709ea28e-1573-c023-8bf8-520c8bc637fa"));
90 AnimsLLUUID.Add("ANIM_AGENT_KISS_MY_BUTT", new LLUUID("19999406-3a3a-d58c-a2ac-d72e555dcf51"));
91 AnimsLLUUID.Add("ANIM_AGENT_LAND", new LLUUID("7a17b059-12b2-41b1-570a-186368b6aa6f"));
92 AnimsLLUUID.Add("ANIM_AGENT_LAUGH_SHORT", new LLUUID("ca5b3f14-3194-7a2b-c894-aa699b718d1f"));
93 AnimsLLUUID.Add("ANIM_AGENT_MEDIUM_LAND", new LLUUID("f4f00d6e-b9fe-9292-f4cb-0ae06ea58d57"));
94 AnimsLLUUID.Add("ANIM_AGENT_MOTORCYCLE_SIT", new LLUUID("08464f78-3a8e-2944-cba5-0c94aff3af29"));
95 AnimsLLUUID.Add("ANIM_AGENT_MUSCLE_BEACH", new LLUUID("315c3a41-a5f3-0ba4-27da-f893f769e69b"));
96 AnimsLLUUID.Add("ANIM_AGENT_NO", new LLUUID("5a977ed9-7f72-44e9-4c4c-6e913df8ae74"));
97 AnimsLLUUID.Add("ANIM_AGENT_NO_UNHAPPY", new LLUUID("d83fa0e5-97ed-7eb2-e798-7bd006215cb4"));
98 AnimsLLUUID.Add("ANIM_AGENT_NYAH_NYAH", new LLUUID("f061723d-0a18-754f-66ee-29a44795a32f"));
99 AnimsLLUUID.Add("ANIM_AGENT_ONETWO_PUNCH", new LLUUID("eefc79be-daae-a239-8c04-890f5d23654a"));
100 AnimsLLUUID.Add("ANIM_AGENT_PEACE", new LLUUID("b312b10e-65ab-a0a4-8b3c-1326ea8e3ed9"));
101 AnimsLLUUID.Add("ANIM_AGENT_POINT_ME", new LLUUID("17c024cc-eef2-f6a0-3527-9869876d7752"));
102 AnimsLLUUID.Add("ANIM_AGENT_POINT_YOU", new LLUUID("ec952cca-61ef-aa3b-2789-4d1344f016de"));
103 AnimsLLUUID.Add("ANIM_AGENT_PRE_JUMP", new LLUUID("7a4e87fe-de39-6fcb-6223-024b00893244"));
104 AnimsLLUUID.Add("ANIM_AGENT_PUNCH_LEFT", new LLUUID("f3300ad9-3462-1d07-2044-0fef80062da0"));
105 AnimsLLUUID.Add("ANIM_AGENT_PUNCH_RIGHT", new LLUUID("c8e42d32-7310-6906-c903-cab5d4a34656"));
106 AnimsLLUUID.Add("ANIM_AGENT_REPULSED", new LLUUID("36f81a92-f076-5893-dc4b-7c3795e487cf"));
107 AnimsLLUUID.Add("ANIM_AGENT_ROUNDHOUSE_KICK", new LLUUID("49aea43b-5ac3-8a44-b595-96100af0beda"));
108 AnimsLLUUID.Add("ANIM_AGENT_RPS_COUNTDOWN", new LLUUID("35db4f7e-28c2-6679-cea9-3ee108f7fc7f"));
109 AnimsLLUUID.Add("ANIM_AGENT_RPS_PAPER", new LLUUID("0836b67f-7f7b-f37b-c00a-460dc1521f5a"));
110 AnimsLLUUID.Add("ANIM_AGENT_RPS_ROCK", new LLUUID("42dd95d5-0bc6-6392-f650-777304946c0f"));
111 AnimsLLUUID.Add("ANIM_AGENT_RPS_SCISSORS", new LLUUID("16803a9f-5140-e042-4d7b-d28ba247c325"));
112 AnimsLLUUID.Add("ANIM_AGENT_RUN", new LLUUID("05ddbff8-aaa9-92a1-2b74-8fe77a29b445"));
113 AnimsLLUUID.Add("ANIM_AGENT_SAD", new LLUUID("0eb702e2-cc5a-9a88-56a5-661a55c0676a"));
114 AnimsLLUUID.Add("ANIM_AGENT_SALUTE", new LLUUID("cd7668a6-7011-d7e2-ead8-fc69eff1a104"));
115 AnimsLLUUID.Add("ANIM_AGENT_SHOOT_BOW_L", new LLUUID("e04d450d-fdb5-0432-fd68-818aaf5935f8"));
116 AnimsLLUUID.Add("ANIM_AGENT_SHOUT", new LLUUID("6bd01860-4ebd-127a-bb3d-d1427e8e0c42"));
117 AnimsLLUUID.Add("ANIM_AGENT_SHRUG", new LLUUID("70ea714f-3a97-d742-1b01-590a8fcd1db5"));
118 AnimsLLUUID.Add("ANIM_AGENT_SIT", new LLUUID("1a5fe8ac-a804-8a5d-7cbd-56bd83184568"));
119 AnimsLLUUID.Add("ANIM_AGENT_SIT_FEMALE", new LLUUID("b1709c8d-ecd3-54a1-4f28-d55ac0840782"));
120 AnimsLLUUID.Add("ANIM_AGENT_SIT_GENERIC", new LLUUID("245f3c54-f1c0-bf2e-811f-46d8eeb386e7"));
121 AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND", new LLUUID("1c7600d6-661f-b87b-efe2-d7421eb93c86"));
122 AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND_CONSTRAINED", new LLUUID("1a2bd58e-87ff-0df8-0b4c-53e047b0bb6e"));
123 AnimsLLUUID.Add("ANIM_AGENT_SIT_TO_STAND", new LLUUID("a8dee56f-2eae-9e7a-05a2-6fb92b97e21e"));
124 AnimsLLUUID.Add("ANIM_AGENT_SLEEP", new LLUUID("f2bed5f9-9d44-39af-b0cd-257b2a17fe40"));
125 AnimsLLUUID.Add("ANIM_AGENT_SMOKE_IDLE", new LLUUID("d2f2ee58-8ad1-06c9-d8d3-3827ba31567a"));
126 AnimsLLUUID.Add("ANIM_AGENT_SMOKE_INHALE", new LLUUID("6802d553-49da-0778-9f85-1599a2266526"));
127 AnimsLLUUID.Add("ANIM_AGENT_SMOKE_THROW_DOWN", new LLUUID("0a9fb970-8b44-9114-d3a9-bf69cfe804d6"));
128 AnimsLLUUID.Add("ANIM_AGENT_SNAPSHOT", new LLUUID("eae8905b-271a-99e2-4c0e-31106afd100c"));
129 AnimsLLUUID.Add("ANIM_AGENT_STAND", new LLUUID("2408fe9e-df1d-1d7d-f4ff-1384fa7b350f"));
130 AnimsLLUUID.Add("ANIM_AGENT_STANDUP", new LLUUID("3da1d753-028a-5446-24f3-9c9b856d9422"));
131 AnimsLLUUID.Add("ANIM_AGENT_STAND_1", new LLUUID("15468e00-3400-bb66-cecc-646d7c14458e"));
132 AnimsLLUUID.Add("ANIM_AGENT_STAND_2", new LLUUID("370f3a20-6ca6-9971-848c-9a01bc42ae3c"));
133 AnimsLLUUID.Add("ANIM_AGENT_STAND_3", new LLUUID("42b46214-4b44-79ae-deb8-0df61424ff4b"));
134 AnimsLLUUID.Add("ANIM_AGENT_STAND_4", new LLUUID("f22fed8b-a5ed-2c93-64d5-bdd8b93c889f"));
135 AnimsLLUUID.Add("ANIM_AGENT_STRETCH", new LLUUID("80700431-74ec-a008-14f8-77575e73693f"));
136 AnimsLLUUID.Add("ANIM_AGENT_STRIDE", new LLUUID("1cb562b0-ba21-2202-efb3-30f82cdf9595"));
137 AnimsLLUUID.Add("ANIM_AGENT_SURF", new LLUUID("41426836-7437-7e89-025d-0aa4d10f1d69"));
138 AnimsLLUUID.Add("ANIM_AGENT_SURPRISE", new LLUUID("313b9881-4302-73c0-c7d0-0e7a36b6c224"));
139 AnimsLLUUID.Add("ANIM_AGENT_SWORD_STRIKE", new LLUUID("85428680-6bf9-3e64-b489-6f81087c24bd"));
140 AnimsLLUUID.Add("ANIM_AGENT_TALK", new LLUUID("5c682a95-6da4-a463-0bf6-0f5b7be129d1"));
141 AnimsLLUUID.Add("ANIM_AGENT_TANTRUM", new LLUUID("11000694-3f41-adc2-606b-eee1d66f3724"));
142 AnimsLLUUID.Add("ANIM_AGENT_THROW_R", new LLUUID("aa134404-7dac-7aca-2cba-435f9db875ca"));
143 AnimsLLUUID.Add("ANIM_AGENT_TRYON_SHIRT", new LLUUID("83ff59fe-2346-f236-9009-4e3608af64c1"));
144 AnimsLLUUID.Add("ANIM_AGENT_TURNLEFT", new LLUUID("56e0ba0d-4a9f-7f27-6117-32f2ebbf6135"));
145 AnimsLLUUID.Add("ANIM_AGENT_TURNRIGHT", new LLUUID("2d6daa51-3192-6794-8e2e-a15f8338ec30"));
146 AnimsLLUUID.Add("ANIM_AGENT_TYPE", new LLUUID("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9"));
147 AnimsLLUUID.Add("ANIM_AGENT_WALK", new LLUUID("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0"));
148 AnimsLLUUID.Add("ANIM_AGENT_WHISPER", new LLUUID("7693f268-06c7-ea71-fa21-2b30d6533f8f"));
149 AnimsLLUUID.Add("ANIM_AGENT_WHISTLE", new LLUUID("b1ed7982-c68e-a982-7561-52a88a5298c0"));
150 AnimsLLUUID.Add("ANIM_AGENT_WINK", new LLUUID("869ecdad-a44b-671e-3266-56aef2e3ac2e"));
151 AnimsLLUUID.Add("ANIM_AGENT_WINK_HOLLYWOOD", new LLUUID("c0c4030f-c02b-49de-24ba-2331f43fe41c"));
152 AnimsLLUUID.Add("ANIM_AGENT_WORRY", new LLUUID("9f496bd2-589a-709f-16cc-69bf7df1d36c"));
153 AnimsLLUUID.Add("ANIM_AGENT_YES", new LLUUID("15dd911d-be82-2856-26db-27659b142875"));
154 AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d"));
155 AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb"));
156
157 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.world.Avatar.Animations.AnimsLLUUID)
158 {
159 AnimsNames.Add(kp.Value, kp.Key);
160 }
161 }
162 }
163}
diff --git a/OpenSim/OpenSim.RegionServer/world/Entity.cs b/OpenSim/OpenSim.RegionServer/world/Entity.cs
new file mode 100644
index 0000000..96e039a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Entity.cs
@@ -0,0 +1,124 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Axiom.MathLib;
5using OpenSim.Physics.Manager;
6using OpenSim.types;
7using libsecondlife;
8using OpenSim.RegionServer.world.scripting;
9
10namespace OpenSim.world
11{
12 public abstract class Entity : IScriptReadonlyEntity
13 {
14 public libsecondlife.LLUUID uuid;
15 public uint localid;
16 public LLVector3 velocity;
17 public Quaternion rotation;
18 protected List<Entity> children;
19
20 protected string m_name;
21 public virtual string Name
22 {
23 get { return m_name; }
24 }
25
26 protected LLVector3 m_pos;
27 protected PhysicsActor _physActor;
28 protected World m_world;
29
30 public virtual LLVector3 Pos
31 {
32 get
33 {
34 if (this._physActor != null)
35 {
36 m_pos.X = _physActor.Position.X;
37 m_pos.Y = _physActor.Position.Y;
38 m_pos.Z = _physActor.Position.Z;
39 }
40
41 return m_pos;
42 }
43 set
44 {
45 if (this._physActor != null)
46 {
47 try
48 {
49 lock (this.m_world.LockPhysicsEngine)
50 {
51
52 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
53 }
54 }
55 catch (Exception e)
56 {
57 Console.WriteLine(e.Message);
58 }
59 }
60
61 m_pos = value;
62 }
63 }
64
65 /// <summary>
66 /// Creates a new Entity (should not occur on it's own)
67 /// </summary>
68 public Entity()
69 {
70 uuid = new libsecondlife.LLUUID();
71 localid = 0;
72 m_pos = new LLVector3();
73 velocity = new LLVector3();
74 rotation = new Quaternion();
75 m_name = "(basic entity)";
76 children = new List<Entity>();
77 }
78
79 public virtual void addForces()
80 {
81 foreach (Entity child in children)
82 {
83 child.addForces();
84 }
85 }
86
87 /// <summary>
88 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
89 /// </summary>
90 public virtual void update() {
91 // Do any per-frame updates needed that are applicable to every type of entity
92 foreach (Entity child in children)
93 {
94 child.update();
95 }
96 }
97
98 /// <summary>
99 /// Returns a mesh for this object and any dependents
100 /// </summary>
101 /// <returns>The mesh of this entity tree</returns>
102 public virtual Mesh getMesh()
103 {
104 Mesh mesh = new Mesh();
105
106 foreach (Entity child in children)
107 {
108 mesh += child.getMesh();
109 }
110
111 return mesh;
112 }
113
114 public virtual void BackUp()
115 {
116
117 }
118
119 public virtual void LandRenegerated()
120 {
121
122 }
123 }
124}
diff --git a/OpenSim/OpenSim.RegionServer/world/Primitive.cs b/OpenSim/OpenSim.RegionServer/world/Primitive.cs
new file mode 100644
index 0000000..e048a9e
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Primitive.cs
@@ -0,0 +1,570 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Physics.Manager;
9using OpenSim.Framework.Types;
10
11namespace OpenSim.world
12{
13 public class Primitive : Entity
14 {
15 protected float mesh_cutbegin;
16 protected float mesh_cutend;
17 protected PrimData primData;
18 protected bool newPrimFlag = false;
19 protected bool updateFlag = false;
20 protected bool dirtyFlag = false;
21 private ObjectUpdatePacket OurPacket;
22 private bool physicsEnabled = false;
23 private bool physicstest = false;
24 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
25 private Dictionary<uint, ClientView> m_clientThreads;
26 private ulong m_regionHandle;
27 private const uint FULL_MASK_PERMISSIONS = 2147483647;
28
29 public bool PhysicsEnabled
30 {
31 get
32 {
33 return physicsEnabled;
34 }
35 set
36 {
37 physicsEnabled = value;
38 }
39 }
40 public bool UpdateFlag
41 {
42 get
43 {
44 return updateFlag;
45 }
46 set
47 {
48 updateFlag = value;
49 }
50 }
51 public LLVector3 Scale
52 {
53 set
54 {
55 LLVector3 offset = (value - primData.Scale);
56 offset.X /= 2;
57 offset.Y /= 2;
58 offset.Z /= 2;
59
60 this.primData.Position += offset;
61 this.primData.Scale = value;
62
63 this.dirtyFlag = true;
64 }
65 get
66 {
67 return this.primData.Scale;
68 }
69 }
70 public PhysicsActor PhysActor
71 {
72 set
73 {
74 this._physActor = value;
75 }
76 }
77
78 public Primitive(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
79 {
80 mesh_cutbegin = 0.0f;
81 mesh_cutend = 1.0f;
82
83 m_clientThreads = clientThreads;
84 m_regionHandle = regionHandle;
85 m_world = world;
86 }
87
88 public override Mesh getMesh()
89 {
90 Mesh mesh = new Mesh();
91 Triangle tri = new Triangle(
92 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
93 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
94 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
95
96 mesh.AddTri(tri);
97 mesh += base.getMesh();
98
99 return mesh;
100 }
101
102 public byte[] GetByteArray()
103 {
104 return this.primData.ToBytes();
105 }
106
107 public void GetProperites(ClientView client)
108 {
109 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
110 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
111 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
112 proper.ObjectData[0].ItemID = LLUUID.Zero; // this.uuid;
113 proper.ObjectData[0].CreationDate = (ulong) this.primData.CreationDate;
114 proper.ObjectData[0].CreatorID = this.primData.OwnerID;
115 proper.ObjectData[0].FolderID = LLUUID.Zero;
116 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
117 proper.ObjectData[0].GroupID = LLUUID.Zero;
118 proper.ObjectData[0].InventorySerial = 0;
119 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
120 proper.ObjectData[0].ObjectID = this.uuid;
121 proper.ObjectData[0].OwnerID = primData.OwnerID;
122 proper.ObjectData[0].TouchName = new byte[0];
123 proper.ObjectData[0].TextureID = new byte[0];
124 proper.ObjectData[0].SitName = new byte[0];
125 proper.ObjectData[0].Name = new byte[0];
126 proper.ObjectData[0].Description = new byte[0];
127 proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
128 proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
129 proper.ObjectData[0].GroupMask = this.primData.GroupMask;
130 proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
131 proper.ObjectData[0].BaseMask = this.primData.BaseMask;
132
133 client.OutPacket(proper);
134 }
135
136 public void UpdatePosition(LLVector3 pos)
137 {
138 this.Pos = pos;
139 if (this._physActor != null) // && this.physicsEnabled)
140 {
141 try
142 {
143 lock (m_world.LockPhysicsEngine)
144 {
145 this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
146 }
147 }
148 catch (Exception e)
149 {
150 Console.WriteLine(e.Message);
151 }
152 }
153 this.updateFlag = true;
154 }
155
156 public override void update()
157 {
158 LLVector3 pos2 = new LLVector3(0, 0, 0);
159 if (this._physActor != null && this.physicsEnabled)
160 {
161
162 PhysicsVector pPos = this._physActor.Position;
163 pos2 = new LLVector3(pPos.X, pPos.Y, pPos.Z);
164 }
165 if (this.newPrimFlag)
166 {
167 foreach (ClientView client in m_clientThreads.Values)
168 {
169 client.OutPacket(OurPacket);
170 }
171 this.newPrimFlag = false;
172 }
173 else if (this.updateFlag)
174 {
175 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
176 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
177 terse.RegionData.TimeDilation = 64096;
178 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
179 terse.ObjectData[0] = this.CreateImprovedBlock();
180 foreach (ClientView client in m_clientThreads.Values)
181 {
182 client.OutPacket(terse);
183 }
184 this.updateFlag = false;
185 }
186 else if (this.dirtyFlag)
187 {
188 foreach (ClientView client in m_clientThreads.Values)
189 {
190 UpdateClient(client);
191 }
192 this.dirtyFlag = false;
193 }
194 else
195 {
196 if (this._physActor != null && this.physicsEnabled)
197 {
198 if (pos2 != this.positionLastFrame)
199 {
200 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
201 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
202 terse.RegionData.TimeDilation = 64096;
203 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
204 terse.ObjectData[0] = this.CreateImprovedBlock();
205 foreach (ClientView client in m_clientThreads.Values)
206 {
207 client.OutPacket(terse);
208 }
209 }
210 this.positionLastFrame = pos2;
211 }
212 }
213
214 if (this.physicstest)
215 {
216 LLVector3 pos = this.Pos;
217 pos.Z += 0.0001f;
218 this.UpdatePosition(pos);
219 this.physicstest = false;
220 }
221 }
222
223 public void UpdateClient(ClientView RemoteClient)
224 {
225
226 LLVector3 lPos;
227 if (this._physActor != null && this.physicsEnabled)
228 {
229 PhysicsVector pPos = this._physActor.Position;
230 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
231 }
232 else
233 {
234 lPos = this.Pos;
235 }
236 byte[] pb = lPos.GetBytes();
237 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
238
239 // OurPacket should be update with the follwing in updateShape() rather than having to do it here
240 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
241 OurPacket.ObjectData[0].PCode = this.primData.PCode;
242 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
243 OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd;
244 OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX;
245 OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY;
246 OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX;
247 OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY;
248 OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew;
249 OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
250 OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
251 OurPacket.ObjectData[0].Scale = this.primData.Scale;
252 OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve;
253 OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
254 OurPacket.ObjectData[0].ParentID = this.primData.ParentID ;
255 OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
256 //finish off copying rest of shape data
257 OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
258 OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
259 OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX;
260 OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY;
261 OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist;
262 OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin;
263
264 RemoteClient.OutPacket(OurPacket);
265 }
266
267 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
268 {
269 this.primData.PathBegin = addPacket.PathBegin;
270 this.primData.PathEnd = addPacket.PathEnd;
271 this.primData.PathScaleX = addPacket.PathScaleX;
272 this.primData.PathScaleY = addPacket.PathScaleY;
273 this.primData.PathShearX = addPacket.PathShearX;
274 this.primData.PathShearY = addPacket.PathShearY;
275 this.primData.PathSkew = addPacket.PathSkew;
276 this.primData.ProfileBegin = addPacket.ProfileBegin;
277 this.primData.ProfileEnd = addPacket.ProfileEnd;
278 this.primData.PathCurve = addPacket.PathCurve;
279 this.primData.ProfileCurve = addPacket.ProfileCurve;
280 this.primData.ProfileHollow = addPacket.ProfileHollow;
281 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
282 this.primData.PathRevolutions = addPacket.PathRevolutions;
283 this.primData.PathTaperX = addPacket.PathTaperX;
284 this.primData.PathTaperY = addPacket.PathTaperY;
285 this.primData.PathTwist = addPacket.PathTwist;
286 this.primData.PathTwistBegin = addPacket.PathTwistBegin;
287 this.dirtyFlag = true;
288 }
289
290 public void UpdateTexture(byte[] tex)
291 {
292 this.OurPacket.ObjectData[0].TextureEntry = tex;
293 this.primData.Texture = tex;
294 this.dirtyFlag = true;
295 }
296
297 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
298 {
299 if (this._physActor != null)
300 {
301 if (this._physActor.Kinematic == pack.AgentData.UsePhysics)
302 {
303 this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false
304 }
305 this.physicsEnabled = pack.AgentData.UsePhysics;
306 if (this._physActor.Kinematic == false)
307 {
308 LLVector3 pos = this.Pos;
309 this.UpdatePosition(pos);
310 pos.Z += 0.000001f;
311 this.UpdatePosition(pos);
312 this.physicstest = true;
313 }
314 else
315 {
316 PhysicsVector vec = this._physActor.Position;
317 LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z);
318 this.Pos = pos;
319 this.updateFlag = true;
320 }
321 }
322 }
323
324 public void MakeParent(Primitive prim)
325 {
326 this.primData.ParentID = prim.localid;
327 this.Pos -= prim.Pos;
328 this.dirtyFlag = true;
329 }
330
331 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
332 {
333 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
334 objupdate.RegionData.RegionHandle = m_regionHandle;
335 objupdate.RegionData.TimeDilation = 64096;
336
337 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
338 PrimData PData = new PrimData();
339 this.primData = PData;
340 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
341
342 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
343 objupdate.ObjectData[0].PSBlock = new byte[0];
344 objupdate.ObjectData[0].ExtraParams = new byte[1];
345 objupdate.ObjectData[0].MediaURL = new byte[0];
346 objupdate.ObjectData[0].NameValue = new byte[0];
347 objupdate.ObjectData[0].Text = new byte[0];
348 objupdate.ObjectData[0].TextColor = new byte[4];
349 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
350 objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
351 objupdate.ObjectData[0].Material = 3;
352 objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
353 objupdate.ObjectData[0].TextureAnim = new byte[0];
354 objupdate.ObjectData[0].Sound = LLUUID.Zero;
355 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
356 this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
357 objupdate.ObjectData[0].State = 0;
358 objupdate.ObjectData[0].Data = new byte[0];
359 PData.OwnerID = objupdate.ObjectData[0].OwnerID = ownerID;
360 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
361 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
362 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
363 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
364 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
365 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
366 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
367 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
368 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
369 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
370 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
371 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
372 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
373 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
374 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
375 PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
376 PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
377 PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
378 PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
379 PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
380 PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
381 objupdate.ObjectData[0].ID = (uint)(localID);
382 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000"));
383 objupdate.ObjectData[0].ObjectData = new byte[60];
384 objupdate.ObjectData[0].ObjectData[46] = 128;
385 objupdate.ObjectData[0].ObjectData[47] = 63;
386 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
387 //update position
388 byte[] pb = pos1.GetBytes();
389 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
390 this.newPrimFlag = true;
391 this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID;
392 this.localid = objupdate.ObjectData[0].ID;
393 this.primData.Position = this.Pos = pos1;
394 this.OurPacket = objupdate;
395 }
396
397 public void CreateFromStorage(PrimData store)
398 {
399 this.CreateFromStorage(store, store.Position, store.LocalID, false);
400 }
401
402 public void CreateFromStorage(PrimData store, LLVector3 posi, uint localID, bool newprim)
403 {
404 //need to clean this up as it shares a lot of code with CreateFromPacket()
405 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
406 objupdate.RegionData.RegionHandle = m_regionHandle;
407 objupdate.RegionData.TimeDilation = 64096;
408 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
409
410 this.primData = store;
411 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
412 objupdate.ObjectData[0].PSBlock = new byte[0];
413 objupdate.ObjectData[0].ExtraParams = new byte[1];
414 objupdate.ObjectData[0].MediaURL = new byte[0];
415 objupdate.ObjectData[0].NameValue = new byte[0];
416 objupdate.ObjectData[0].Text = new byte[0];
417 objupdate.ObjectData[0].TextColor = new byte[4];
418 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
419 objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
420 objupdate.ObjectData[0].Material = 3;
421 objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
422 objupdate.ObjectData[0].TextureAnim = new byte[0];
423 objupdate.ObjectData[0].Sound = LLUUID.Zero;
424
425 if (store.Texture == null)
426 {
427 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
428 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
429 }
430 else
431 {
432 objupdate.ObjectData[0].TextureEntry = store.Texture;
433 }
434
435 objupdate.ObjectData[0].State = 0;
436 objupdate.ObjectData[0].Data = new byte[0];
437 objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
438 objupdate.ObjectData[0].PCode = this.primData.PCode;
439 objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
440 objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
441 objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
442 objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
443 objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
444 objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
445 objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
446 objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
447 objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
448 objupdate.ObjectData[0].Scale = this.primData.Scale;
449 objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
450 objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
451 objupdate.ObjectData[0].ParentID = 0;
452 objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
453 //finish off copying rest of shape data
454 objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
455 objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
456 objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX;
457 objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY;
458 objupdate.ObjectData[0].PathTwist = this.primData.PathTwist;
459 objupdate.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin;
460
461 objupdate.ObjectData[0].ID = localID; // (uint)store.LocalID;
462 objupdate.ObjectData[0].FullID = store.FullID;
463
464 objupdate.ObjectData[0].ObjectData = new byte[60];
465 objupdate.ObjectData[0].ObjectData[46] = 128;
466 objupdate.ObjectData[0].ObjectData[47] = 63;
467 LLVector3 pos1 = posi; // store.Position;
468 //update position
469 byte[] pb = pos1.GetBytes();
470 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
471
472 this.uuid = objupdate.ObjectData[0].FullID;
473 this.localid = objupdate.ObjectData[0].ID;
474 this.Pos = pos1;
475 this.OurPacket = objupdate;
476 if (newprim)
477 {
478 this.newPrimFlag = true;
479 }
480 }
481
482 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
483 {
484 uint ID = this.localid;
485 byte[] bytes = new byte[60];
486
487 int i = 0;
488 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
489 //dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
490 dat.TextureEntry = new byte[0];
491 //Console.WriteLine("texture-entry length in improvedterse block is " + this.OurPacket.ObjectData[0].TextureEntry.Length);
492 bytes[i++] = (byte)(ID % 256);
493 bytes[i++] = (byte)((ID >> 8) % 256);
494 bytes[i++] = (byte)((ID >> 16) % 256);
495 bytes[i++] = (byte)((ID >> 24) % 256);
496 bytes[i++] = 0;
497 bytes[i++] = 0;
498
499 LLVector3 lPos;
500 Axiom.MathLib.Quaternion lRot;
501 if (this._physActor != null && this.physicsEnabled)
502 {
503 PhysicsVector pPos = this._physActor.Position;
504 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
505 lRot = this._physActor.Orientation;
506 }
507 else
508 {
509 lPos = this.Pos;
510 lRot = this.rotation;
511 }
512 byte[] pb = lPos.GetBytes();
513 Array.Copy(pb, 0, bytes, i, pb.Length);
514 i += 12;
515 ushort ac = 32767;
516
517 //vel
518 bytes[i++] = (byte)(ac % 256);
519 bytes[i++] = (byte)((ac >> 8) % 256);
520 bytes[i++] = (byte)(ac % 256);
521 bytes[i++] = (byte)((ac >> 8) % 256);
522 bytes[i++] = (byte)(ac % 256);
523 bytes[i++] = (byte)((ac >> 8) % 256);
524
525 //accel
526 bytes[i++] = (byte)(ac % 256);
527 bytes[i++] = (byte)((ac >> 8) % 256);
528 bytes[i++] = (byte)(ac % 256);
529 bytes[i++] = (byte)((ac >> 8) % 256);
530 bytes[i++] = (byte)(ac % 256);
531 bytes[i++] = (byte)((ac >> 8) % 256);
532
533 ushort rw, rx, ry, rz;
534 rw = (ushort)(32768 * (lRot.w + 1));
535 rx = (ushort)(32768 * (lRot.x + 1));
536 ry = (ushort)(32768 * (lRot.y + 1));
537 rz = (ushort)(32768 * (lRot.z + 1));
538
539 //rot
540 bytes[i++] = (byte)(rx % 256);
541 bytes[i++] = (byte)((rx >> 8) % 256);
542 bytes[i++] = (byte)(ry % 256);
543 bytes[i++] = (byte)((ry >> 8) % 256);
544 bytes[i++] = (byte)(rz % 256);
545 bytes[i++] = (byte)((rz >> 8) % 256);
546 bytes[i++] = (byte)(rw % 256);
547 bytes[i++] = (byte)((rw >> 8) % 256);
548
549 //rotation vel
550 bytes[i++] = (byte)(ac % 256);
551 bytes[i++] = (byte)((ac >> 8) % 256);
552 bytes[i++] = (byte)(ac % 256);
553 bytes[i++] = (byte)((ac >> 8) % 256);
554 bytes[i++] = (byte)(ac % 256);
555 bytes[i++] = (byte)((ac >> 8) % 256);
556
557 dat.Data = bytes;
558 return dat;
559 }
560
561 public override void BackUp()
562 {
563 this.primData.FullID = this.uuid;
564 this.primData.LocalID = this.localid;
565 this.primData.Position = this.Pos;
566 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w);
567 this.m_world.localStorage.StorePrim(this.primData);
568 }
569 }
570}
diff --git a/OpenSim/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim/OpenSim.RegionServer/world/Primitive2.cs
new file mode 100644
index 0000000..6d071d4
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Primitive2.cs
@@ -0,0 +1,491 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Physics.Manager;
9using OpenSim.Framework.Types;
10using OpenSim.Framework.Inventory;
11
12namespace OpenSim.world
13{
14 public class Primitive2 : Entity
15 {
16 protected PrimData primData;
17 //private ObjectUpdatePacket OurPacket;
18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
19 private Dictionary<uint, ClientView> m_clientThreads;
20 private ulong m_regionHandle;
21 private const uint FULL_MASK_PERMISSIONS = 2147483647;
22 private bool physicsEnabled = false;
23
24 private Dictionary<LLUUID, InventoryItem> inventoryItems;
25
26 #region Properties
27
28 public LLVector3 Scale
29 {
30 set
31 {
32 this.primData.Scale = value;
33 //this.dirtyFlag = true;
34 }
35 get
36 {
37 return this.primData.Scale;
38 }
39 }
40
41 public PhysicsActor PhysActor
42 {
43 set
44 {
45 this._physActor = value;
46 }
47 }
48 public override LLVector3 Pos
49 {
50 get
51 {
52 return base.Pos;
53 }
54 set
55 {
56 base.Pos = value;
57 }
58 }
59 #endregion
60
61 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
62 {
63 m_clientThreads = clientThreads;
64 m_regionHandle = regionHandle;
65 m_world = world;
66 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
67 }
68
69 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner)
70 {
71 m_clientThreads = clientThreads;
72 m_regionHandle = regionHandle;
73 m_world = world;
74 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
75 this.primData = new PrimData();
76 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
77 this.primData.OwnerID = owner;
78 }
79
80 public byte[] GetByteArray()
81 {
82 byte[] result = null;
83 List<byte[]> dataArrays = new List<byte[]>();
84 dataArrays.Add(primData.ToBytes());
85 foreach (Entity child in children)
86 {
87 if (child is OpenSim.world.Primitive2)
88 {
89 dataArrays.Add(((OpenSim.world.Primitive2)child).GetByteArray());
90 }
91 }
92 byte[] primstart = Helpers.StringToField("<Prim>");
93 byte[] primend = Helpers.StringToField("</Prim>");
94 int totalLength = primstart.Length + primend.Length;
95 for (int i = 0; i < dataArrays.Count; i++)
96 {
97 totalLength += dataArrays[i].Length;
98 }
99
100 result = new byte[totalLength];
101 int arraypos = 0;
102 Array.Copy(primstart, 0, result, 0, primstart.Length);
103 arraypos += primstart.Length;
104 for (int i = 0; i < dataArrays.Count; i++)
105 {
106 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
107 arraypos += dataArrays[i].Length;
108 }
109 Array.Copy(primend, 0, result, arraypos, primend.Length);
110
111 return result;
112 }
113
114 #region Overridden Methods
115
116 public override void update()
117 {
118 LLVector3 pos2 = new LLVector3(0, 0, 0);
119 }
120
121 public override void BackUp()
122 {
123
124 }
125
126 #endregion
127
128 #region Packet handlers
129
130 public void UpdatePosition(LLVector3 pos)
131 {
132
133 }
134
135 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
136 {
137 this.primData.PathBegin = addPacket.PathBegin;
138 this.primData.PathEnd = addPacket.PathEnd;
139 this.primData.PathScaleX = addPacket.PathScaleX;
140 this.primData.PathScaleY = addPacket.PathScaleY;
141 this.primData.PathShearX = addPacket.PathShearX;
142 this.primData.PathShearY = addPacket.PathShearY;
143 this.primData.PathSkew = addPacket.PathSkew;
144 this.primData.ProfileBegin = addPacket.ProfileBegin;
145 this.primData.ProfileEnd = addPacket.ProfileEnd;
146 this.primData.PathCurve = addPacket.PathCurve;
147 this.primData.ProfileCurve = addPacket.ProfileCurve;
148 this.primData.ProfileHollow = addPacket.ProfileHollow;
149 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
150 this.primData.PathRevolutions = addPacket.PathRevolutions;
151 this.primData.PathTaperX = addPacket.PathTaperX;
152 this.primData.PathTaperY = addPacket.PathTaperY;
153 this.primData.PathTwist = addPacket.PathTwist;
154 this.primData.PathTwistBegin = addPacket.PathTwistBegin;
155 }
156
157 public void UpdateTexture(byte[] tex)
158 {
159 this.primData.Texture = tex;
160 //this.dirtyFlag = true;
161 }
162
163 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
164 {
165
166 }
167
168 public void AssignToParent(Primitive prim)
169 {
170
171 }
172
173 public void GetProperites(ClientView client)
174 {
175 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
176 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
177 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
178 proper.ObjectData[0].ItemID = LLUUID.Zero;
179 proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate;
180 proper.ObjectData[0].CreatorID = this.primData.OwnerID;
181 proper.ObjectData[0].FolderID = LLUUID.Zero;
182 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
183 proper.ObjectData[0].GroupID = LLUUID.Zero;
184 proper.ObjectData[0].InventorySerial = 0;
185 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
186 proper.ObjectData[0].ObjectID = this.uuid;
187 proper.ObjectData[0].OwnerID = primData.OwnerID;
188 proper.ObjectData[0].TouchName = new byte[0];
189 proper.ObjectData[0].TextureID = new byte[0];
190 proper.ObjectData[0].SitName = new byte[0];
191 proper.ObjectData[0].Name = new byte[0];
192 proper.ObjectData[0].Description = new byte[0];
193 proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
194 proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
195 proper.ObjectData[0].GroupMask = this.primData.GroupMask;
196 proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
197 proper.ObjectData[0].BaseMask = this.primData.BaseMask;
198
199 client.OutPacket(proper);
200 }
201
202 #endregion
203
204 # region Inventory Methods
205
206 public bool AddToInventory(InventoryItem item)
207 {
208 return false;
209 }
210
211 public InventoryItem RemoveFromInventory(LLUUID itemID)
212 {
213 return null;
214 }
215
216 public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet)
217 {
218
219 }
220
221 public void RequestXferInventory(ClientView simClient, ulong xferID)
222 {
223 //will only currently work if the total size of the inventory data array is under about 1000 bytes
224 SendXferPacketPacket send = new SendXferPacketPacket();
225
226 send.XferID.ID = xferID;
227 send.XferID.Packet = 1 + 2147483648;
228 send.DataPacket.Data = this.ConvertInventoryToBytes();
229
230 simClient.OutPacket(send);
231 }
232
233 public byte[] ConvertInventoryToBytes()
234 {
235 System.Text.Encoding enc = System.Text.Encoding.ASCII;
236 byte[] result = new byte[0];
237 List<byte[]> inventoryData = new List<byte[]>();
238 int totallength = 0;
239 foreach (InventoryItem invItem in inventoryItems.Values)
240 {
241 byte[] data = enc.GetBytes(invItem.ExportString());
242 inventoryData.Add(data);
243 totallength += data.Length;
244 }
245 //TODO: copy arrays into the single result array
246
247 return result;
248 }
249
250 public void CreateInventoryFromBytes(byte[] data)
251 {
252
253 }
254
255 #endregion
256
257 #region Update viewers Methods
258
259 //should change these mehtods, so that outgoing packets are sent through the avatar class
260 public void SendFullUpdateToClient(ClientView remoteClient)
261 {
262 LLVector3 lPos;
263 if (this._physActor != null && this.physicsEnabled)
264 {
265 PhysicsVector pPos = this._physActor.Position;
266 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
267 }
268 else
269 {
270 lPos = this.Pos;
271 }
272
273 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
274 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
275 outPacket.ObjectData[0] = this.CreateUpdateBlock();
276 byte[] pb = lPos.GetBytes();
277 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
278
279 remoteClient.OutPacket(outPacket);
280 }
281
282 public void SendFullUpdateToAllClients()
283 {
284
285 }
286
287 public void SendTerseUpdateToClient(ClientView RemoteClient)
288 {
289
290 }
291
292 public void SendTerseUpdateToALLClients()
293 {
294
295 }
296
297 #endregion
298
299 #region Create Methods
300
301 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
302 {
303 PrimData PData = new PrimData();
304 this.primData = PData;
305 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
306
307 PData.OwnerID = ownerID;
308 PData.PCode = addPacket.ObjectData.PCode;
309 PData.PathBegin = addPacket.ObjectData.PathBegin;
310 PData.PathEnd = addPacket.ObjectData.PathEnd;
311 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
312 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
313 PData.PathShearX = addPacket.ObjectData.PathShearX;
314 PData.PathShearY = addPacket.ObjectData.PathShearY;
315 PData.PathSkew = addPacket.ObjectData.PathSkew;
316 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
317 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
318 PData.Scale = addPacket.ObjectData.Scale;
319 PData.PathCurve = addPacket.ObjectData.PathCurve;
320 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
321 PData.ParentID = 0;
322 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
323 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
324 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
325 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
326 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
327 PData.PathTwist = addPacket.ObjectData.PathTwist;
328 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
329 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
330 this.primData.FullID = this.uuid = LLUUID.Random();
331 this.localid = (uint)(localID);
332 this.primData.Position = this.Pos = pos1;
333 }
334
335 public void CreateFromBytes(byte[] data)
336 {
337
338 }
339
340 public void CreateFromPrimData(PrimData primData)
341 {
342 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
343 }
344
345 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
346 {
347
348 }
349
350 #endregion
351
352 #region Packet Update Methods
353 protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
354 {
355 objdata.PSBlock = new byte[0];
356 objdata.ExtraParams = new byte[1];
357 objdata.MediaURL = new byte[0];
358 objdata.NameValue = new byte[0];
359 objdata.Text = new byte[0];
360 objdata.TextColor = new byte[4];
361 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
362 objdata.JointPivot = new LLVector3(0, 0, 0);
363 objdata.Material = 3;
364 objdata.TextureAnim = new byte[0];
365 objdata.Sound = LLUUID.Zero;
366 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
367 this.primData.Texture = objdata.TextureEntry = ntex.ToBytes();
368 objdata.State = 0;
369 objdata.Data = new byte[0];
370
371 objdata.ObjectData = new byte[60];
372 objdata.ObjectData[46] = 128;
373 objdata.ObjectData[47] = 63;
374 }
375
376 protected void SetPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData)
377 {
378 objectData.OwnerID = this.primData.OwnerID;
379 objectData.PCode = this.primData.PCode;
380 objectData.PathBegin = this.primData.PathBegin;
381 objectData.PathEnd = this.primData.PathEnd;
382 objectData.PathScaleX = this.primData.PathScaleX;
383 objectData.PathScaleY = this.primData.PathScaleY;
384 objectData.PathShearX = this.primData.PathShearX;
385 objectData.PathShearY = this.primData.PathShearY;
386 objectData.PathSkew = this.primData.PathSkew;
387 objectData.ProfileBegin = this.primData.ProfileBegin;
388 objectData.ProfileEnd = this.primData.ProfileEnd;
389 objectData.Scale = this.primData.Scale;
390 objectData.PathCurve = this.primData.PathCurve;
391 objectData.ProfileCurve = this.primData.ProfileCurve;
392 objectData.ParentID = this.primData.ParentID;
393 objectData.ProfileHollow = this.primData.ProfileHollow;
394 objectData.PathRadiusOffset = this.primData.PathRadiusOffset;
395 objectData.PathRevolutions = this.primData.PathRevolutions;
396 objectData.PathTaperX = this.primData.PathTaperX;
397 objectData.PathTaperY = this.primData.PathTaperY;
398 objectData.PathTwist = this.primData.PathTwist;
399 objectData.PathTwistBegin = this.primData.PathTwistBegin;
400 }
401
402 #endregion
403 protected ObjectUpdatePacket.ObjectDataBlock CreateUpdateBlock()
404 {
405 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
406 this.SetDefaultPacketValues(objupdate);
407 objupdate.UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
408 this.SetPacketShapeData(objupdate);
409 byte[] pb = this.Pos.GetBytes();
410 Array.Copy(pb, 0, objupdate.ObjectData, 0, pb.Length);
411 return objupdate;
412 }
413
414 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
415 {
416 uint ID = this.localid;
417 byte[] bytes = new byte[60];
418
419 int i = 0;
420 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
421 dat.TextureEntry = new byte[0];
422 bytes[i++] = (byte)(ID % 256);
423 bytes[i++] = (byte)((ID >> 8) % 256);
424 bytes[i++] = (byte)((ID >> 16) % 256);
425 bytes[i++] = (byte)((ID >> 24) % 256);
426 bytes[i++] = 0;
427 bytes[i++] = 0;
428
429 LLVector3 lPos;
430 Axiom.MathLib.Quaternion lRot;
431 if (this._physActor != null && this.physicsEnabled)
432 {
433 PhysicsVector pPos = this._physActor.Position;
434 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
435 lRot = this._physActor.Orientation;
436 }
437 else
438 {
439 lPos = this.Pos;
440 lRot = this.rotation;
441 }
442 byte[] pb = lPos.GetBytes();
443 Array.Copy(pb, 0, bytes, i, pb.Length);
444 i += 12;
445 ushort ac = 32767;
446
447 //vel
448 bytes[i++] = (byte)(ac % 256);
449 bytes[i++] = (byte)((ac >> 8) % 256);
450 bytes[i++] = (byte)(ac % 256);
451 bytes[i++] = (byte)((ac >> 8) % 256);
452 bytes[i++] = (byte)(ac % 256);
453 bytes[i++] = (byte)((ac >> 8) % 256);
454
455 //accel
456 bytes[i++] = (byte)(ac % 256);
457 bytes[i++] = (byte)((ac >> 8) % 256);
458 bytes[i++] = (byte)(ac % 256);
459 bytes[i++] = (byte)((ac >> 8) % 256);
460 bytes[i++] = (byte)(ac % 256);
461 bytes[i++] = (byte)((ac >> 8) % 256);
462
463 ushort rw, rx, ry, rz;
464 rw = (ushort)(32768 * (lRot.w + 1));
465 rx = (ushort)(32768 * (lRot.x + 1));
466 ry = (ushort)(32768 * (lRot.y + 1));
467 rz = (ushort)(32768 * (lRot.z + 1));
468
469 //rot
470 bytes[i++] = (byte)(rx % 256);
471 bytes[i++] = (byte)((rx >> 8) % 256);
472 bytes[i++] = (byte)(ry % 256);
473 bytes[i++] = (byte)((ry >> 8) % 256);
474 bytes[i++] = (byte)(rz % 256);
475 bytes[i++] = (byte)((rz >> 8) % 256);
476 bytes[i++] = (byte)(rw % 256);
477 bytes[i++] = (byte)((rw >> 8) % 256);
478
479 //rotation vel
480 bytes[i++] = (byte)(ac % 256);
481 bytes[i++] = (byte)((ac >> 8) % 256);
482 bytes[i++] = (byte)(ac % 256);
483 bytes[i++] = (byte)((ac >> 8) % 256);
484 bytes[i++] = (byte)(ac % 256);
485 bytes[i++] = (byte)((ac >> 8) % 256);
486
487 dat.Data = bytes;
488 return dat;
489 }
490 }
491}
diff --git a/OpenSim/OpenSim.RegionServer/world/SceneObject.cs b/OpenSim/OpenSim.RegionServer/world/SceneObject.cs
new file mode 100644
index 0000000..a846fb5
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/SceneObject.cs
@@ -0,0 +1,77 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Physics.Manager;
9using OpenSim.Framework.Types;
10using OpenSim.Framework.Inventory;
11
12namespace OpenSim.world
13{
14 public class SceneObject : Entity
15 {
16 private LLUUID rootUUID;
17 private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>();
18 private Dictionary<uint, ClientView> m_clientThreads;
19 private World m_world;
20
21 public SceneObject()
22 {
23
24 }
25
26 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
27 {
28 }
29
30 public void CreateFromBytes(byte[] data)
31 {
32
33 }
34
35 public override void update()
36 {
37
38 }
39
40 public override void BackUp()
41 {
42
43 }
44
45 public void GetProperites(ClientView client)
46 {
47 /*
48 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
49 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
50 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
51 proper.ObjectData[0].ItemID = LLUUID.Zero;
52 proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate;
53 proper.ObjectData[0].CreatorID = this.primData.OwnerID;
54 proper.ObjectData[0].FolderID = LLUUID.Zero;
55 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
56 proper.ObjectData[0].GroupID = LLUUID.Zero;
57 proper.ObjectData[0].InventorySerial = 0;
58 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
59 proper.ObjectData[0].ObjectID = this.uuid;
60 proper.ObjectData[0].OwnerID = primData.OwnerID;
61 proper.ObjectData[0].TouchName = new byte[0];
62 proper.ObjectData[0].TextureID = new byte[0];
63 proper.ObjectData[0].SitName = new byte[0];
64 proper.ObjectData[0].Name = new byte[0];
65 proper.ObjectData[0].Description = new byte[0];
66 proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
67 proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
68 proper.ObjectData[0].GroupMask = this.primData.GroupMask;
69 proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
70 proper.ObjectData[0].BaseMask = this.primData.BaseMask;
71
72 client.OutPacket(proper);
73 * */
74 }
75
76 }
77}
diff --git a/OpenSim/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/world/World.PacketHandlers.cs
new file mode 100644
index 0000000..4f32335
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/World.PacketHandlers.cs
@@ -0,0 +1,368 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Physics.Manager;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9using OpenSim.Framework.Terrain;
10using OpenSim.Framework.Inventory;
11using OpenSim.Framework.Utilities;
12using OpenSim.Assets;
13
14namespace OpenSim.world
15{
16 public partial class World
17 {
18 public void ModifyTerrain(byte action, float north, float west)
19 {
20 switch (action)
21 {
22 case 1:
23 // raise terrain
24 Terrain.raise(north, west, 10.0, 0.001);
25 RegenerateTerrain(true, (int)north, (int)west);
26 break;
27 case 2:
28 //lower terrain
29 Terrain.lower(north, west, 10.0, 0.001);
30 RegenerateTerrain(true, (int)north, (int)west);
31 break;
32 }
33 return;
34 }
35
36 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
37 {
38 foreach (ClientView client in m_clientThreads.Values)
39 {
40 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
41 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
42
43 switch (type)
44 {
45 case 0: // Whisper
46 if ((dis < 10) && (dis > -10))
47 {
48 //should change so the message is sent through the avatar rather than direct to the ClientView
49 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
50 }
51 break;
52 case 1: // Say
53 if ((dis < 30) && (dis > -30))
54 {
55 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
56 }
57 break;
58 case 2: // Shout
59 if ((dis < 100) && (dis > -100))
60 {
61 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
62 }
63 break;
64
65 case 0xff: // Broadcast
66 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
67 break;
68 }
69
70 }
71 }
72
73 public void RezObject(AssetBase primAsset, LLVector3 pos)
74 {
75 PrimData primd = new PrimData(primAsset.Data);
76 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
77 nPrim.CreateFromStorage(primd, pos, this._primCount, true);
78 this.Entities.Add(nPrim.uuid, nPrim);
79 this._primCount++;
80 }
81
82 public void DeRezObject(Packet packet, ClientView simClient)
83 {
84 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
85
86 //Needs to delete object from physics at a later date
87 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
88 {
89 //currently following code not used (or don't know of any case of destination being zero
90 libsecondlife.LLUUID[] DeRezEnts;
91 DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length];
92 int i = 0;
93 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
94 {
95
96 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
97 foreach (Entity ent in this.Entities.Values)
98 {
99 if (ent.localid == Data.ObjectLocalID)
100 {
101 DeRezEnts[i++] = ent.uuid;
102 this.localStorage.RemovePrim(ent.uuid);
103 KillObjectPacket kill = new KillObjectPacket();
104 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
105 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
106 kill.ObjectData[0].ID = ent.localid;
107 foreach (ClientView client in m_clientThreads.Values)
108 {
109 client.OutPacket(kill);
110 }
111 //Uncommenting this means an old UUID will be re-used, thus crashing the asset server
112 //Uncomment when prim/object UUIDs are random or such
113 //2007-03-22 - Randomskk
114 //this._primCount--;
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Deleted UUID " + ent.uuid);
116 }
117 }
118 }
119 foreach (libsecondlife.LLUUID uuid in DeRezEnts)
120 {
121 lock (Entities)
122 {
123 Entities.Remove(uuid);
124 }
125 }
126 }
127 else
128 {
129 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
130 {
131 Entity selectedEnt = null;
132 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
133 foreach (Entity ent in this.Entities.Values)
134 {
135 if (ent.localid == Data.ObjectLocalID)
136 {
137 AssetBase primAsset = new AssetBase();
138 primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
139 primAsset.InvType = 6;
140 primAsset.Type = 6;
141 primAsset.Name = "Prim";
142 primAsset.Description = "";
143 primAsset.Data = ((Primitive)ent).GetByteArray();
144 this._assetCache.AddAsset(primAsset);
145 this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
146 selectedEnt = ent;
147 break;
148 }
149 }
150 if (selectedEnt != null)
151 {
152 this.localStorage.RemovePrim(selectedEnt.uuid);
153 KillObjectPacket kill = new KillObjectPacket();
154 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
155 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
156 kill.ObjectData[0].ID = selectedEnt.localid;
157 foreach (ClientView client in m_clientThreads.Values)
158 {
159 client.OutPacket(kill);
160 }
161 lock (Entities)
162 {
163 Entities.Remove(selectedEnt.uuid);
164 }
165 }
166 }
167 }
168
169 }
170
171 public void SendAvatarsToClient(ClientView remoteClient)
172 {
173 foreach (ClientView client in m_clientThreads.Values)
174 {
175 if (client.AgentID != remoteClient.AgentID)
176 {
177 // ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
178 // RemoteClient.OutPacket(objupdate);
179 client.ClientAvatar.SendUpdateToOtherClient(remoteClient.ClientAvatar);
180 client.ClientAvatar.SendAppearanceToOtherAgent(remoteClient.ClientAvatar);
181 }
182 }
183 }
184
185 public void LinkObjects(uint parentPrim, List<uint> childPrims)
186 {
187 Primitive parentprim = null;
188 foreach (Entity ent in Entities.Values)
189 {
190 if (ent.localid == parentPrim)
191 {
192 parentprim = (OpenSim.world.Primitive)ent;
193
194 }
195 }
196
197 for (int i = 0; i < childPrims.Count; i++)
198 {
199 uint childId = childPrims[i];
200 foreach (Entity ent in Entities.Values)
201 {
202 if (ent.localid == childId)
203 {
204 ((OpenSim.world.Primitive)ent).MakeParent(parentprim);
205 }
206 }
207 }
208
209 }
210
211 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
212 {
213 foreach (Entity ent in Entities.Values)
214 {
215 if (ent.localid == primLocalID)
216 {
217 ((OpenSim.world.Primitive)ent).UpdateShape(shapeBlock);
218 break;
219 }
220 }
221 }
222
223 public void SelectPrim(uint primLocalID, ClientView remoteClient)
224 {
225 foreach (Entity ent in Entities.Values)
226 {
227 if (ent.localid == primLocalID)
228 {
229 ((OpenSim.world.Primitive)ent).GetProperites(remoteClient);
230 break;
231 }
232 }
233 }
234
235 public void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient)
236 {
237 foreach (Entity ent in Entities.Values)
238 {
239 if (ent.localid == localID)
240 {
241 ((OpenSim.world.Primitive)ent).UpdateObjectFlags((ObjectFlagUpdatePacket) packet);
242 break;
243 }
244 }
245 }
246
247 public void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient)
248 {
249 foreach (Entity ent in Entities.Values)
250 {
251 if (ent.localid == localID)
252 {
253 ((OpenSim.world.Primitive)ent).UpdateTexture(texture);
254 break;
255 }
256 }
257 }
258
259 public void UpdatePrimPosition(uint localID, LLVector3 pos, ClientView remoteClient)
260 {
261 foreach (Entity ent in Entities.Values)
262 {
263 if (ent.localid == localID)
264 {
265 ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
266 break;
267 }
268 }
269 }
270
271 public void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient)
272 {
273 foreach (Entity ent in Entities.Values)
274 {
275 if (ent.localid == localID)
276 {
277 ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
278 ((OpenSim.world.Primitive)ent).UpdateFlag = true;
279 break;
280 }
281 }
282 }
283
284 public void UpdatePrimScale(uint localID, LLVector3 scale, ClientView remoteClient)
285 {
286 foreach (Entity ent in Entities.Values)
287 {
288 if (ent.localid == localID)
289 {
290 ((OpenSim.world.Primitive)ent).Scale = scale;
291 break;
292 }
293 }
294 }
295
296 /*
297 public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY)
298 {
299 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
300 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))
301 {
302 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
303 mapReply.AgentData.AgentID = simClient.AgentID;
304 mapReply.AgentData.Flags = 0;
305 mapReply.Data = new MapBlockReplyPacket.DataBlock[1];
306 mapReply.Data[0] = new MapBlockReplyPacket.DataBlock();
307 mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000007");
308 mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX;
309 mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY;
310 mapReply.Data[0].WaterHeight = (byte)m_regInfo.RegionWaterHeight;
311 mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName);
312 mapReply.Data[0].RegionFlags = 72458694;
313 mapReply.Data[0].Access = 13;
314 mapReply.Data[0].Agents = 1; //should send number of clients connected
315 simClient.OutPacket(mapReply);
316 }
317 }
318 public bool RezObjectHandler(ClientView simClient, Packet packet)
319 {
320 RezObjectPacket rezPacket = (RezObjectPacket)packet;
321 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
322 if (inven != null)
323 {
324 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
325 {
326 AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
327 if (asset != null)
328 {
329 PrimData primd = new PrimData(asset.Data);
330 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
331 nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
332 this.Entities.Add(nPrim.uuid, nPrim);
333 this._primCount++;
334 this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
335 }
336 }
337 }
338 return true;
339 }
340 public bool ModifyTerrain(ClientView simClient, Packet packet)
341 {
342 ModifyLandPacket modify = (ModifyLandPacket)packet;
343
344 switch (modify.ModifyBlock.Action)
345 {
346 case 1:
347 // raise terrain
348 if (modify.ParcelData.Length > 0)
349 {
350 Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
351 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
352 }
353 break;
354 case 2:
355 //lower terrain
356 if (modify.ParcelData.Length > 0)
357 {
358 Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
359 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
360 }
361 break;
362 }
363 return true;
364 }
365 */
366
367 }
368}
diff --git a/OpenSim/OpenSim.RegionServer/world/World.Scripting.cs b/OpenSim/OpenSim.RegionServer/world/World.Scripting.cs
new file mode 100644
index 0000000..44ef05a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/World.Scripting.cs
@@ -0,0 +1,124 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Reflection;
6using OpenSim.Framework;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9using libsecondlife;
10
11namespace OpenSim.world
12{
13 public partial class World
14 {
15 private Dictionary<string, IScriptEngine> scriptEngines = new Dictionary<string, IScriptEngine>();
16
17 private void LoadScriptEngines()
18 {
19 this.LoadScriptPlugins();
20 }
21
22 public void LoadScriptPlugins()
23 {
24 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines");
25 string[] pluginFiles = Directory.GetFiles(path, "*.dll");
26
27
28 for (int i = 0; i < pluginFiles.Length; i++)
29 {
30 this.AddPlugin(pluginFiles[i]);
31 }
32 }
33
34 private void AddPlugin(string FileName)
35 {
36 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
37
38 foreach (Type pluginType in pluginAssembly.GetTypes())
39 {
40 if (pluginType.IsPublic)
41 {
42 if (!pluginType.IsAbstract)
43 {
44 Type typeInterface = pluginType.GetInterface("IScriptEngine", true);
45
46 if (typeInterface != null)
47 {
48 IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
49 plug.Init(this);
50 this.scriptEngines.Add(plug.GetName(), plug);
51
52 }
53
54 typeInterface = null;
55 }
56 }
57 }
58
59 pluginAssembly = null;
60 }
61
62 public void LoadScript(string scriptType, string scriptName, string script, Entity ent)
63 {
64 if(this.scriptEngines.ContainsKey(scriptType))
65 {
66 this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.localid);
67 }
68 }
69
70 #region IScriptAPI Methods
71
72 public OSVector3 GetEntityPosition(uint localID)
73 {
74 OSVector3 res = new OSVector3();
75 // Console.WriteLine("script- getting entity " + localID + " position");
76 foreach (Entity entity in this.Entities.Values)
77 {
78 if (entity.localid == localID)
79 {
80 res.X = entity.Pos.X;
81 res.Y = entity.Pos.Y;
82 res.Z = entity.Pos.Z;
83 }
84 }
85 return res;
86 }
87
88 public void SetEntityPosition(uint localID, float x , float y, float z)
89 {
90 foreach (Entity entity in this.Entities.Values)
91 {
92 if (entity.localid == localID && entity is Primitive)
93 {
94 LLVector3 pos = entity.Pos;
95 pos.X = x;
96 pos.Y = y;
97 Primitive prim = entity as Primitive;
98 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
99 prim.UpdatePosition(pos);
100 // Console.WriteLine("script- setting entity " + localID + " positon");
101 }
102 }
103
104 }
105
106 public uint GetRandomAvatarID()
107 {
108 //Console.WriteLine("script- getting random avatar id");
109 uint res = 0;
110 foreach (Entity entity in this.Entities.Values)
111 {
112 if (entity is Avatar)
113 {
114 res = entity.localid;
115 }
116 }
117 return res;
118 }
119
120 #endregion
121
122
123 }
124}
diff --git a/OpenSim/OpenSim.RegionServer/world/World.cs b/OpenSim/OpenSim.RegionServer/world/World.cs
new file mode 100644
index 0000000..bb24011
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/World.cs
@@ -0,0 +1,657 @@
1using System;
2using libsecondlife;
3using libsecondlife.Packets;
4using System.Collections.Generic;
5using System.Text;
6using System.Reflection;
7using System.IO;
8using System.Threading;
9using OpenSim.Physics.Manager;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Types;
12using OpenSim.Framework.Terrain;
13using OpenSim.Framework.Inventory;
14using OpenSim.Assets;
15//using OpenSim.world.scripting;
16using OpenSim.RegionServer.world.scripting;
17using OpenSim.Terrain;
18
19namespace OpenSim.world
20{
21 public partial class World : WorldBase, ILocalStorageReceiver, IScriptAPI
22 {
23 public object LockPhysicsEngine = new object();
24 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
25 public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
26 //public ScriptEngine Scripts;
27 public uint _localNumber = 0;
28 private PhysicsScene phyScene;
29 private float timeStep = 0.1f;
30 public ILocalStorage localStorage;
31 private Random Rand = new Random();
32 private uint _primCount = 702000;
33 private int storageCount;
34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
35 private Dictionary<string, ScriptFactory> m_scripts;
36 private Mutex updateLock;
37 public string m_datastore;
38
39 #region Properties
40 public PhysicsScene PhysScene
41 {
42 set
43 {
44 this.phyScene = value;
45 }
46 get
47 {
48 return (this.phyScene);
49 }
50 }
51 #endregion
52
53 #region Constructors
54 /// <summary>
55 /// Creates a new World class, and a region to go with it.
56 /// </summary>
57 /// <param name="clientThreads">Dictionary to contain client threads</param>
58 /// <param name="regionHandle">Region Handle for this region</param>
59 /// <param name="regionName">Region Name for this region</param>
60 public World(Dictionary<uint, ClientView> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
61 {
62 try
63 {
64 updateLock = new Mutex(false);
65 m_clientThreads = clientThreads;
66 m_regionHandle = regionHandle;
67 m_regionName = regionName;
68 m_regInfo = regInfo;
69
70 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
71 m_scripts = new Dictionary<string, ScriptFactory>();
72
73 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating new entitities instance");
74 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
75 Avatars = new Dictionary<LLUUID, Avatar>();
76 Prims = new Dictionary<LLUUID, Primitive>();
77
78 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating LandMap");
79 TerrainManager = new TerrainManager(new SecondLife());
80 Terrain = new TerrainEngine();
81 Avatar.SetupTemplate("avatar-texture.dat");
82 // MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
83 // Initialise this only after the world has loaded
84 // Scripts = new ScriptEngine(this);
85 Avatar.LoadAnims();
86 this.SetDefaultScripts();
87 this.LoadScriptEngines();
88 }
89 catch (Exception e)
90 {
91 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "World.cs: Constructor failed with exception " + e.ToString());
92 }
93 }
94 #endregion
95
96 #region Script Methods
97 /// <summary>
98 /// Loads a new script into the specified entity
99 /// </summary>
100 /// <param name="entity">Entity to be scripted</param>
101 /// <param name="script">The script to load</param>
102 public void AddScript(Entity entity, Script script)
103 {
104 try
105 {
106 ScriptHandler scriptHandler = new ScriptHandler(script, entity, this);
107 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
108 }
109 catch (Exception e)
110 {
111 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddScript() - Failed with exception " + e.ToString());
112 }
113 }
114
115 /// <summary>
116 /// Loads a new script into the specified entity, using a script loaded from a string.
117 /// </summary>
118 /// <param name="entity">The entity to be scripted</param>
119 /// <param name="scriptData">The string containing the script</param>
120 public void AddScript(Entity entity, string scriptData)
121 {
122 try
123 {
124 int scriptstart = 0;
125 int scriptend = 0;
126 string substring;
127 scriptstart = scriptData.LastIndexOf("<Script>");
128 scriptend = scriptData.LastIndexOf("</Script>");
129 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
130 substring = substring.Trim();
131 //Console.WriteLine("searching for script to add: " + substring);
132
133 ScriptFactory scriptFactory;
134 //Console.WriteLine("script string is " + substring);
135 if (substring.StartsWith("<ScriptEngine:"))
136 {
137 string substring1 = "";
138 string script = "";
139 // Console.WriteLine("searching for script engine");
140 substring1 = substring.Remove(0, 14);
141 int dev = substring1.IndexOf(',');
142 string sEngine = substring1.Substring(0, dev);
143 substring1 = substring1.Remove(0, dev + 1);
144 int end = substring1.IndexOf('>');
145 string sName = substring1.Substring(0, end);
146 //Console.WriteLine(" script info : " + sEngine + " , " + sName);
147 int startscript = substring.IndexOf('>');
148 script = substring.Remove(0, startscript + 1);
149 // Console.WriteLine("script data is " + script);
150 if (this.scriptEngines.ContainsKey(sEngine))
151 {
152 this.scriptEngines[sEngine].LoadScript(script, sName, entity.localid);
153 }
154 }
155 else if (this.m_scripts.TryGetValue(substring, out scriptFactory))
156 {
157 //Console.WriteLine("added script");
158 this.AddScript(entity, scriptFactory());
159 }
160 }
161 catch (Exception e)
162 {
163 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddScript() - Failed with exception " + e.ToString());
164 }
165 }
166
167 #endregion
168
169 #region Update Methods
170 /// <summary>
171 /// Performs per-frame updates on the world, this should be the central world loop
172 /// </summary>
173 public override void Update()
174 {
175 updateLock.WaitOne();
176 try
177 {
178 if (this.phyScene.IsThreaded)
179 {
180 this.phyScene.GetResults();
181
182 }
183
184 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
185 {
186 Entities[UUID].addForces();
187 }
188
189 lock (this.LockPhysicsEngine)
190 {
191 this.phyScene.Simulate(timeStep);
192 }
193
194 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
195 {
196 Entities[UUID].update();
197 }
198
199 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
200 {
201 scriptHandler.OnFrame();
202 }
203 foreach (IScriptEngine scripteng in this.scriptEngines.Values)
204 {
205 scripteng.OnFrame();
206 }
207 //backup world data
208 this.storageCount++;
209 if (storageCount > 1200) //set to how often you want to backup
210 {
211 this.Backup();
212 storageCount = 0;
213 }
214 }
215 catch (Exception e)
216 {
217 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: Update() - Failed with exception " + e.ToString());
218 }
219 updateLock.ReleaseMutex();
220 }
221
222 public bool Backup()
223 {
224 try
225 {
226 // Terrain backup routines
227 if (Terrain.tainted > 0)
228 {
229 Terrain.tainted = 0;
230 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain tainted, saving.");
231 localStorage.SaveMap(Terrain.getHeights1D());
232 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain saved, informing Physics.");
233 lock (this.LockPhysicsEngine)
234 {
235 phyScene.SetTerrain(Terrain.getHeights1D());
236 }
237 }
238
239 // Primitive backup routines
240 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Backing up Primitives");
241 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
242 {
243 Entities[UUID].BackUp();
244 }
245
246 // Backup successful
247 return true;
248 }
249 catch (Exception e)
250 {
251 // Backup failed
252 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString());
253 return false;
254 }
255 }
256 #endregion
257
258 #region Setup Methods
259 /// <summary>
260 /// Loads a new storage subsystem from a named library
261 /// </summary>
262 /// <param name="dllName">Storage Library</param>
263 /// <returns>Successful or not</returns>
264 public bool LoadStorageDLL(string dllName)
265 {
266 try
267 {
268 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
269 ILocalStorage store = null;
270
271 foreach (Type pluginType in pluginAssembly.GetTypes())
272 {
273 if (pluginType.IsPublic)
274 {
275 if (!pluginType.IsAbstract)
276 {
277 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
278
279 if (typeInterface != null)
280 {
281 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
282 store = plug;
283
284 store.Initialise(this.m_datastore);
285 break;
286 }
287
288 typeInterface = null;
289 }
290 }
291 }
292 pluginAssembly = null;
293 this.localStorage = store;
294 return (store == null);
295 }
296 catch (Exception e)
297 {
298 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
299 return false;
300 }
301 }
302
303 public void SetDefaultScripts()
304 {
305 this.m_scripts.Add("FollowRandomAvatar", delegate()
306 {
307 return new OpenSim.RegionServer.world.scripting.FollowRandomAvatar();
308 });
309 }
310
311 #endregion
312
313 #region Regenerate Terrain
314
315 /// <summary>
316 /// Rebuilds the terrain using a procedural algorithm
317 /// </summary>
318 public void RegenerateTerrain()
319 {
320 try
321 {
322 Terrain.hills();
323
324 lock (this.LockPhysicsEngine)
325 {
326 this.phyScene.SetTerrain(Terrain.getHeights1D());
327 }
328 this.localStorage.SaveMap(this.Terrain.getHeights1D());
329
330 foreach (ClientView client in m_clientThreads.Values)
331 {
332 this.SendLayerData(client);
333 }
334
335 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
336 {
337 Entities[UUID].LandRenegerated();
338 }
339 }
340 catch (Exception e)
341 {
342 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
343 }
344 }
345
346 /// <summary>
347 /// Rebuilds the terrain using a 2D float array
348 /// </summary>
349 /// <param name="newMap">256,256 float array containing heights</param>
350 public void RegenerateTerrain(float[,] newMap)
351 {
352 try
353 {
354 this.Terrain.setHeights2D(newMap);
355 lock (this.LockPhysicsEngine)
356 {
357 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
358 }
359 this.localStorage.SaveMap(this.Terrain.getHeights1D());
360
361 foreach (ClientView client in m_clientThreads.Values)
362 {
363 this.SendLayerData(client);
364 }
365
366 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
367 {
368 Entities[UUID].LandRenegerated();
369 }
370 }
371 catch (Exception e)
372 {
373 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
374 }
375 }
376
377 /// <summary>
378 /// Rebuilds the terrain assuming changes occured at a specified point[?]
379 /// </summary>
380 /// <param name="changes">???</param>
381 /// <param name="pointx">???</param>
382 /// <param name="pointy">???</param>
383 public void RegenerateTerrain(bool changes, int pointx, int pointy)
384 {
385 try
386 {
387 if (changes)
388 {
389 /* Dont save here, rely on tainting system instead */
390
391 foreach (ClientView client in m_clientThreads.Values)
392 {
393 this.SendLayerData(pointx, pointy, client);
394 }
395 }
396 }
397 catch (Exception e)
398 {
399 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
400 }
401 }
402
403 #endregion
404
405 #region Load Terrain
406 /// <summary>
407 /// Loads the World heightmap
408 /// </summary>
409 public override void LoadWorldMap()
410 {
411 try
412 {
413 float[] map = this.localStorage.LoadWorld();
414 if (map == null)
415 {
416 Console.WriteLine("creating new terrain");
417 this.Terrain.hills();
418
419 this.localStorage.SaveMap(this.Terrain.getHeights1D());
420 }
421 else
422 {
423 this.Terrain.setHeights1D(map);
424 }
425 }
426 catch (Exception e)
427 {
428 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
429 }
430 }
431 #endregion
432
433 #region Primitives Methods
434
435 /// <summary>
436 /// Sends prims to a client
437 /// </summary>
438 /// <param name="RemoteClient">Client to send to</param>
439 public void GetInitialPrims(ClientView RemoteClient)
440 {
441 try
442 {
443 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
444 {
445 if (Entities[UUID] is Primitive)
446 {
447 Primitive primitive = Entities[UUID] as Primitive;
448 primitive.UpdateClient(RemoteClient);
449 }
450 }
451 }
452 catch (Exception e)
453 {
454 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: GetInitialPrims() - Failed with exception " + e.ToString());
455 }
456 }
457
458 /// <summary>
459 /// Loads the World's objects
460 /// </summary>
461 public void LoadPrimsFromStorage()
462 {
463 try
464 {
465 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: LoadPrimsFromStorage() - Loading primitives");
466 this.localStorage.LoadPrimitives(this);
467 }
468 catch (Exception e)
469 {
470 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
471 }
472 }
473
474 /// <summary>
475 /// Loads a specific object from storage
476 /// </summary>
477 /// <param name="prim">The object to load</param>
478 public void PrimFromStorage(PrimData prim)
479 {
480 try
481 {
482 if (prim.LocalID >= this._primCount)
483 {
484 _primCount = prim.LocalID + 1;
485 }
486 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
487 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
488 nPrim.CreateFromStorage(prim);
489 this.Entities.Add(nPrim.uuid, nPrim);
490 }
491 catch (Exception e)
492 {
493 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
494 }
495 }
496
497 public void AddNewPrim(Packet addPacket, ClientView agentClient)
498 {
499 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentID);
500 }
501
502 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
503 {
504 try
505 {
506 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: AddNewPrim() - Creating new prim");
507 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
508 prim.CreateFromPacket(addPacket, ownerID, this._primCount);
509 PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
510 PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
511 if (OpenSim.world.Avatar.PhysicsEngineFlying)
512 {
513 lock (this.LockPhysicsEngine)
514 {
515 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
516 }
517 }
518
519 this.Entities.Add(prim.uuid, prim);
520 this._primCount++;
521 }
522 catch (Exception e)
523 {
524 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddNewPrim() - Failed with exception " + e.ToString());
525 }
526 }
527
528 #endregion
529
530 #region Add/Remove Avatar Methods
531
532 public override Avatar AddViewerAgent(ClientView agentClient)
533 {
534 //register for events
535 agentClient.OnChatFromViewer += new ChatFromViewer(this.SimChat);
536 agentClient.OnRezObject += new RezObject(this.RezObject);
537 agentClient.OnModifyTerrain += new ModifyTerrain(this.ModifyTerrain);
538 agentClient.OnRegionHandShakeReply += new ClientView.GenericCall(this.SendLayerData);
539 agentClient.OnRequestWearables += new ClientView.GenericCall(this.GetInitialPrims);
540 agentClient.OnRequestAvatarsData += new ClientView.GenericCall(this.SendAvatarsToClient);
541 agentClient.OnLinkObjects += new LinkObjects(this.LinkObjects);
542 agentClient.OnAddPrim += new ClientView.GenericCall4(this.AddNewPrim);
543 agentClient.OnUpdatePrimShape += new ClientView.UpdateShape(this.UpdatePrimShape);
544 agentClient.OnObjectSelect += new ClientView.ObjectSelect(this.SelectPrim);
545 agentClient.OnUpdatePrimFlags += new ClientView.UpdatePrimFlags(this.UpdatePrimFlags);
546 agentClient.OnUpdatePrimTexture += new ClientView.UpdatePrimTexture(this.UpdatePrimTexture);
547 agentClient.OnUpdatePrimPosition += new ClientView.UpdatePrimVector(this.UpdatePrimPosition);
548 agentClient.OnUpdatePrimRotation += new ClientView.UpdatePrimRotation(this.UpdatePrimRotation);
549 agentClient.OnUpdatePrimScale += new ClientView.UpdatePrimVector(this.UpdatePrimScale);
550 agentClient.OnDeRezObject += new ClientView.GenericCall4(this.DeRezObject);
551 Avatar newAvatar = null;
552 try
553 {
554 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
555 newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20);
556 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Adding new avatar to world");
557 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Starting RegionHandshake ");
558 newAvatar.SendRegionHandshake(this);
559 //if (!agentClient.m_child)
560 //{
561
562 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
563 lock (this.LockPhysicsEngine)
564 {
565 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
566 }
567 // }
568 lock (Entities)
569 {
570 if (!Entities.ContainsKey(agentClient.AgentID))
571 {
572 this.Entities.Add(agentClient.AgentID, newAvatar);
573 }
574 else
575 {
576 Entities[agentClient.AgentID] = newAvatar;
577 }
578 }
579 lock (Avatars)
580 {
581 if (Avatars.ContainsKey(agentClient.AgentID))
582 {
583 Avatars[agentClient.AgentID] = newAvatar;
584 }
585 else
586 {
587 this.Avatars.Add(agentClient.AgentID, newAvatar);
588 }
589 }
590 }
591 catch (Exception e)
592 {
593 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
594 }
595 return newAvatar;
596 }
597
598 public override void RemoveViewerAgent(ClientView agentClient)
599 {
600 try
601 {
602 lock (Entities)
603 {
604 Entities.Remove(agentClient.AgentID);
605 }
606 lock (Avatars)
607 {
608 Avatars.Remove(agentClient.AgentID);
609 }
610 if (agentClient.ClientAvatar.PhysActor != null)
611 {
612 this.phyScene.RemoveAvatar(agentClient.ClientAvatar.PhysActor);
613 }
614 }
615 catch (Exception e)
616 {
617 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RemoveViewerAgent() - Failed with exception " + e.ToString());
618 }
619 }
620 #endregion
621
622 #region Request Avatars List Methods
623 //The idea is to have a group of method that return a list of avatars meeting some requirement
624 // ie it could be all Avatars within a certain range of the calling prim/avatar.
625
626 public List<Avatar> RequestAvatarList()
627 {
628 List<Avatar> result = new List<Avatar>();
629
630 foreach (Avatar avatar in Avatars.Values)
631 {
632 result.Add(avatar);
633 }
634
635 return result;
636 }
637 #endregion
638
639 #region ShutDown
640 /// <summary>
641 /// Tidy before shutdown
642 /// </summary>
643 public override void Close()
644 {
645 try
646 {
647 this.localStorage.ShutDown();
648 }
649 catch (Exception e)
650 {
651 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
652 }
653 }
654 #endregion
655
656 }
657}
diff --git a/OpenSim/OpenSim.RegionServer/world/WorldBase.cs b/OpenSim/OpenSim.RegionServer/world/WorldBase.cs
new file mode 100644
index 0000000..ea71411
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/WorldBase.cs
@@ -0,0 +1,176 @@
1using System;
2using libsecondlife;
3using libsecondlife.Packets;
4using System.Collections.Generic;
5using System.Text;
6using System.Reflection;
7using System.IO;
8using System.Threading;
9using OpenSim.Physics.Manager;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Types;
12using OpenSim.Framework.Terrain;
13using OpenSim.Framework.Inventory;
14using OpenSim.Assets;
15using OpenSim.RegionServer.world.scripting;
16using OpenSim.Terrain;
17
18namespace OpenSim.world
19{
20 public class WorldBase
21 {
22 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
23 protected Dictionary<uint, ClientView> m_clientThreads;
24 protected ulong m_regionHandle;
25 protected string m_regionName;
26 protected InventoryCache _inventoryCache;
27 protected AssetCache _assetCache;
28 protected RegionInfo m_regInfo;
29
30 public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
31 protected libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine
32
33 #region Properties
34 public InventoryCache InventoryCache
35 {
36 set
37 {
38 this._inventoryCache = value;
39 }
40 }
41
42 public AssetCache AssetCache
43 {
44 set
45 {
46 this._assetCache = value;
47 }
48 }
49 #endregion
50
51 #region Constructors
52 public WorldBase()
53 {
54
55 }
56 #endregion
57
58 #region Setup Methods
59 /// <summary>
60 /// Register Packet handler Methods with the packet server (which will register them with the SimClient)
61 /// </summary>
62 /// <param name="packetServer"></param>
63 public virtual void RegisterPacketHandlers(PacketServer packetServer)
64 {
65
66 }
67 #endregion
68
69 #region Update Methods
70 /// <summary>
71 /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation)
72 /// </summary>
73 public virtual void Update()
74 {
75
76 }
77 #endregion
78
79 #region Terrain Methods
80
81 /// <summary>
82 /// Loads the World heightmap
83 /// </summary>
84 public virtual void LoadWorldMap()
85 {
86
87 }
88
89 /// <summary>
90 /// Send the region heightmap to the client
91 /// </summary>
92 /// <param name="RemoteClient">Client to send to</param>
93 public virtual void SendLayerData(ClientView RemoteClient)
94 {
95 try
96 {
97 int[] patches = new int[4];
98
99 for (int y = 0; y < 16; y++)
100 {
101 for (int x = 0; x < 16; x = x + 4)
102 {
103 patches[0] = x + 0 + y * 16;
104 patches[1] = x + 1 + y * 16;
105 patches[2] = x + 2 + y * 16;
106 patches[3] = x + 3 + y * 16;
107
108 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
109 RemoteClient.OutPacket(layerpack);
110 }
111 }
112 }
113 catch (Exception e)
114 {
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: SendLayerData() - Failed with exception " + e.ToString());
116 }
117 }
118
119 /// <summary>
120 /// Sends a specified patch to a client
121 /// </summary>
122 /// <param name="px">Patch coordinate (x) 0..16</param>
123 /// <param name="py">Patch coordinate (y) 0..16</param>
124 /// <param name="RemoteClient">The client to send to</param>
125 public void SendLayerData(int px, int py, ClientView RemoteClient)
126 {
127 try
128 {
129 int[] patches = new int[1];
130 int patchx, patchy;
131 patchx = px / 16;
132 patchy = py / 16;
133
134 patches[0] = patchx + 0 + patchy * 16;
135
136 Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
137 RemoteClient.OutPacket(layerpack);
138 }
139 catch (Exception e)
140 {
141 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: SendLayerData() - Failed with exception " + e.ToString());
142 }
143 }
144 #endregion
145
146 #region Add/Remove Agent/Avatar
147 /// <summary>
148 /// Add a new Agent's avatar
149 /// </summary>
150 /// <param name="agentClient"></param>
151 public virtual Avatar AddViewerAgent(ClientView agentClient)
152 {
153 return null;
154 }
155
156 /// <summary>
157 /// Remove a Agent's avatar
158 /// </summary>
159 /// <param name="agentClient"></param>
160 public virtual void RemoveViewerAgent(ClientView agentClient)
161 {
162
163 }
164 #endregion
165
166 #region Shutdown
167 /// <summary>
168 /// Tidy before shutdown
169 /// </summary>
170 public virtual void Close()
171 {
172
173 }
174 #endregion
175 }
176}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/IScriptContext.cs b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptContext.cs
new file mode 100644
index 0000000..465c23b
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptContext.cs
@@ -0,0 +1,13 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting
7{
8 public interface IScriptContext
9 {
10 IScriptEntity Entity { get; }
11 bool TryGetRandomAvatar(out IScriptReadonlyEntity avatar);
12 }
13}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/IScriptEntity.cs b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptEntity.cs
new file mode 100644
index 0000000..2ef16a4
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptEntity.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting
7{
8 public interface IScriptReadonlyEntity
9 {
10 LLVector3 Pos { get; }
11 string Name { get; }
12 }
13
14 public interface IScriptEntity
15 {
16 LLVector3 Pos { get; set; }
17 string Name { get; }
18 }
19}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/IScriptHandler.cs b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptHandler.cs
new file mode 100644
index 0000000..15efc49
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/IScriptHandler.cs
@@ -0,0 +1,98 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Physics.Manager;
6using OpenSim.world;
7using Avatar=OpenSim.world.Avatar;
8using Primitive = OpenSim.world.Primitive;
9
10namespace OpenSim.RegionServer.world.scripting
11{
12 public delegate void ScriptEventHandler(IScriptContext context);
13
14 public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity
15 {
16 private World m_world;
17 private Script m_script;
18 private Entity m_entity;
19
20 public LLUUID ScriptId
21 {
22 get
23 {
24 return m_script.ScriptId;
25 }
26 }
27
28 public void OnFrame()
29 {
30 m_script.OnFrame(this);
31 }
32
33 public ScriptHandler(Script script, Entity entity, World world)
34 {
35 m_script = script;
36 m_entity = entity;
37 m_world = world;
38 }
39
40 #region IScriptContext Members
41
42 IScriptEntity IScriptContext.Entity
43 {
44 get
45 {
46 return this;
47 }
48 }
49
50 bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar)
51 {
52 foreach (Entity entity in m_world.Entities.Values )
53 {
54 if( entity is Avatar )
55 {
56 avatar = entity;
57 return true;
58 }
59 }
60
61 avatar = null;
62 return false;
63 }
64
65 #endregion
66
67 #region IScriptEntity and IScriptReadonlyEntity Members
68
69 public string Name
70 {
71 get
72 {
73 return m_entity.Name;
74 }
75 }
76
77 public LLVector3 Pos
78 {
79 get
80 {
81 return m_entity.Pos;
82 }
83
84 set
85 {
86 if (m_entity is Primitive)
87 {
88 Primitive prim = m_entity as Primitive;
89 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
90 prim.UpdatePosition( value );
91 }
92 }
93 }
94
95 #endregion
96 }
97
98}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/Script.cs b/OpenSim/OpenSim.RegionServer/world/scripting/Script.cs
new file mode 100644
index 0000000..48c18ff
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/Script.cs
@@ -0,0 +1,26 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting
7{
8 public class Script
9 {
10 private LLUUID m_scriptId;
11 public virtual LLUUID ScriptId
12 {
13 get
14 {
15 return m_scriptId;
16 }
17 }
18
19 public Script( LLUUID scriptId )
20 {
21 m_scriptId = scriptId;
22 }
23
24 public ScriptEventHandler OnFrame;
25 }
26}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/ScriptFactory.cs b/OpenSim/OpenSim.RegionServer/world/scripting/ScriptFactory.cs
new file mode 100644
index 0000000..4c6d373
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/ScriptFactory.cs
@@ -0,0 +1,8 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.RegionServer.world.scripting
6{
7 public delegate Script ScriptFactory();
8}
diff --git a/OpenSim/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
new file mode 100644
index 0000000..6a689ab
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
@@ -0,0 +1,37 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting
7{
8 public class FollowRandomAvatar : Script
9 {
10 public FollowRandomAvatar()
11 : base(LLUUID.Random())
12 {
13 OnFrame += MyOnFrame;
14 }
15
16 private void MyOnFrame(IScriptContext context)
17 {
18 LLVector3 pos = context.Entity.Pos;
19
20 IScriptReadonlyEntity avatar;
21
22 if (context.TryGetRandomAvatar(out avatar))
23 {
24 LLVector3 avatarPos = avatar.Pos;
25
26 float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2;
27 float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2;
28
29 LLVector3 newPos = new LLVector3(x, y, pos.Z);
30
31 context.Entity.Pos = newPos;
32 }
33 }
34 }
35
36
37}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs
new file mode 100644
index 0000000..15ef814
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5
6namespace OpenSim.Scripting.EmbeddedJVM
7{
8 public class ClassInstance : Object
9 {
10 public int size;
11 public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
12
13 public ClassInstance()
14 {
15
16 }
17 }
18}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs
new file mode 100644
index 0000000..f2f0da5
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs
@@ -0,0 +1,476 @@
1using System;
2using System.IO;
3using System.Collections.Generic;
4using System.Text;
5using OpenSim.Scripting.EmbeddedJVM.Types;
6
7namespace OpenSim.Scripting.EmbeddedJVM
8{
9 public class ClassRecord
10 {
11 private ushort _majorVersion;
12 private ushort _minorVersion;
13 private ushort _constantPoolCount;
14 private ushort _accessFlags;
15 private ushort _thisClass;
16 private ushort _supperClass;
17 private ushort _interfaceCount;
18 private ushort _fieldCount;
19 private ushort _methodCount;
20 //private ushort _attributeCount;
21 //private string _name;
22 public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>();
23 public PoolClass mClass;
24
25 public List<PoolItem> _constantsPool = new List<PoolItem>();
26 private List<MethodInfo> _methodsList = new List<MethodInfo>();
27 private List<FieldInfo> _fieldList = new List<FieldInfo>();
28
29 public ClassRecord()
30 {
31
32 }
33
34 public ClassInstance CreateNewInstance()
35 {
36 return new ClassInstance();
37 }
38
39 public void LoadClassFromFile(string fileName)
40 {
41 Console.WriteLine("loading script " + fileName);
42 FileStream fs = File.OpenRead(fileName);
43 this.LoadClassFromBytes(ReadFully(fs));
44 fs.Close();
45 }
46
47 public void LoadClassFromBytes(byte[] data)
48 {
49 int i = 0;
50 i += 4;
51 _minorVersion = (ushort)((data[i++] << 8) + data[i++] );
52 _majorVersion = (ushort)((data[i++] << 8) + data[i++] );
53 _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] );
54 // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
55 for (int count = 0; count < _constantPoolCount -1 ; count++)
56 {
57 //read in the constant pool
58 byte pooltype = data[i++];
59 //Console.WriteLine("#" +count +": new constant type = " +pooltype);
60 //Console.WriteLine("start position is: " + i);
61 switch (pooltype)
62 {
63 case 1: //Utf8
64 ushort uLength = (ushort)((data[i++] << 8) + data[i++] );
65
66 // Console.WriteLine("new utf8 type, length is " + uLength);
67 PoolUtf8 utf8 = new PoolUtf8();
68 utf8.readValue(data, ref i, uLength);
69 this._constantsPool.Add(utf8);
70 break;
71 case 3: //Int
72 break;
73 case 7: //Class
74 PoolClass pClass = new PoolClass(this);
75 pClass.readValue(data, ref i);
76 this._constantsPool.Add(pClass);
77 break;
78 case 10: //Method
79 PoolMethodRef pMeth = new PoolMethodRef(this);
80 pMeth.readValue(data, ref i);
81 this._constantsPool.Add(pMeth);
82 break;
83 case 12: //NamedType
84 PoolNamedType pNamed = new PoolNamedType(this);
85 pNamed.readValue(data, ref i);
86 this._constantsPool.Add(pNamed);
87 break;
88 }
89 }
90
91 _accessFlags = (ushort)((data[i++] << 8) + data[i++] );
92 _thisClass = (ushort)((data[i++] << 8) + data[i++] );
93 _supperClass = (ushort)((data[i++] << 8) + data[i++] );
94
95 if (this._constantsPool[this._thisClass - 1] is PoolClass)
96 {
97 this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]);
98 }
99
100 _interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
101 //should now read in the info for each interface
102 _fieldCount = (ushort)((data[i++] << 8) + data[i++]);
103 //should now read in the info for each field
104 _methodCount = (ushort)((data[i++] << 8) + data[i++]);
105 for (int count = 0; count < _methodCount; count++)
106 {
107 MethodInfo methInf = new MethodInfo(this);
108 methInf.ReadData(data, ref i);
109 this._methodsList.Add(methInf);
110 }
111 }
112
113 public void AddMethodsToMemory(MethodMemory memory)
114 {
115 for (int count = 0; count < _methodCount; count++)
116 {
117 this._methodsList[count].AddMethodCode(memory);
118 }
119 }
120
121 public bool StartMethod(Thread thread, string methodName)
122 {
123 for (int count = 0; count < _methodCount; count++)
124 {
125 if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8)
126 {
127 if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName)
128 {
129 //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
130 thread.SetPC(this._methodsList[count].CodePointer);
131 return true;
132 }
133 }
134 }
135 return false;
136 }
137
138 public void PrintToConsole()
139 {
140 Console.WriteLine("Class File:");
141 Console.WriteLine("Major version: " + _majorVersion);
142 Console.WriteLine("Minor version: " + _minorVersion);
143 Console.WriteLine("Pool size: " + _constantPoolCount);
144
145 for (int i = 0; i < _constantsPool.Count; i++)
146 {
147 this._constantsPool[i].Print();
148 }
149
150 Console.WriteLine("Access flags: " + _accessFlags);
151 Console.WriteLine("This class: " + _thisClass );
152 Console.WriteLine("Super class: " + _supperClass);
153
154 for (int count = 0; count < _methodCount; count++)
155 {
156 Console.WriteLine();
157 this._methodsList[count].Print();
158 }
159
160 Console.WriteLine("class name is " + this.mClass.Name.Value);
161 }
162
163 public static byte[] ReadFully(Stream stream)
164 {
165 byte[] buffer = new byte[1024];
166 using (MemoryStream ms = new MemoryStream())
167 {
168 while (true)
169 {
170 int read = stream.Read(buffer, 0, buffer.Length);
171 if (read <= 0)
172 return ms.ToArray();
173 ms.Write(buffer, 0, read);
174 }
175 }
176 }
177
178 #region nested classes
179 public class PoolItem
180 {
181 public virtual void Print()
182 {
183
184 }
185 }
186
187 public class PoolUtf8 : PoolItem
188 {
189 public string Value = "";
190
191 public void readValue(byte[] data,ref int pointer , int length)
192 {
193 for (int i = 0; i < length; i++)
194 {
195 int a =(int) data[pointer++];
196 if ((a & 0x80) == 0)
197 {
198 Value = Value + (char)a;
199 }
200 else if ((a & 0x20) == 0)
201 {
202 int b = (int) data[pointer++];
203 Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
204 }
205 else
206 {
207 int b = (int)data[pointer++];
208 int c = (int)data[pointer++];
209 Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
210 }
211 }
212 }
213
214 public override void Print()
215 {
216 Console.WriteLine("Utf8 type: " + Value);
217 }
218 }
219
220 private class PoolInt : PoolItem
221 {
222
223 }
224
225 public class PoolClass : PoolItem
226 {
227 //public string name = "";
228 public ushort namePointer = 0;
229 private ClassRecord parent;
230 public PoolUtf8 Name;
231
232 public PoolClass(ClassRecord paren)
233 {
234 parent = paren;
235 }
236
237 public void readValue(byte[] data, ref int pointer)
238 {
239 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
240 }
241
242 public override void Print()
243 {
244 this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
245 Console.Write("Class type: " + namePointer);
246 Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
247
248 }
249 }
250
251 public class PoolMethodRef : PoolItem
252 {
253 public ushort classPointer = 0;
254 public ushort nameTypePointer = 0;
255 public PoolNamedType mNameType;
256 public PoolClass mClass;
257 private ClassRecord parent;
258
259 public PoolMethodRef(ClassRecord paren)
260 {
261 parent = paren;
262 }
263
264 public void readValue(byte[] data, ref int pointer)
265 {
266 classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
267 nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
268 }
269
270 public override void Print()
271 {
272 this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
273 this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
274 Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
275 }
276 }
277
278 public class PoolNamedType : PoolItem
279 {
280 public ushort namePointer = 0;
281 public ushort typePointer = 0;
282 private ClassRecord parent;
283 public PoolUtf8 Name;
284 public PoolUtf8 Type;
285
286 public PoolNamedType(ClassRecord paren)
287 {
288 parent = paren;
289 }
290
291 public void readValue(byte[] data, ref int pointer)
292 {
293 namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
294 typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
295 }
296
297 public override void Print()
298 {
299 Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]);
300 Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]);
301 Console.Write("Named type: " + namePointer + " , " + typePointer );
302 Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value);
303 }
304 }
305
306 //***********************
307 public class MethodInfo
308 {
309 public ushort AccessFlags = 0;
310 public ushort NameIndex = 0;
311 public string Name = "";
312 public ushort DescriptorIndex = 0;
313 public ushort AttributeCount = 0;
314 public List<MethodAttribute> Attributes = new List<MethodAttribute>();
315 private ClassRecord parent;
316 public int CodePointer = 0;
317
318 public MethodInfo(ClassRecord paren)
319 {
320 parent = paren;
321 }
322
323 public void AddMethodCode(MethodMemory memory)
324 {
325 Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length);
326 memory.Methodcount++;
327 this.CodePointer = memory.NextMethodPC;
328 memory.NextMethodPC += this.Attributes[0].Code.Length;
329 }
330
331 public void ReadData(byte[] data, ref int pointer)
332 {
333 AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]);
334 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
335 DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
336 AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
337 for(int i =0; i< AttributeCount; i++)
338 {
339 MethodAttribute attri = new MethodAttribute(this.parent);
340 attri.ReadData(data, ref pointer);
341 this.Attributes.Add(attri);
342 }
343 }
344
345 public void Print()
346 {
347 Console.WriteLine("Method Info Struct: ");
348 Console.WriteLine("AccessFlags: " + AccessFlags);
349 Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
350 Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value);
351 Console.WriteLine("Attribute Count:" + AttributeCount);
352 for (int i = 0; i < AttributeCount; i++)
353 {
354 this.Attributes[i].Print();
355 }
356 }
357
358 public class MethodAttribute
359 {
360 public ushort NameIndex = 0;
361 public string Name = "";
362 public Int32 Length = 0;
363 //for now only support code attribute
364 public ushort MaxStack = 0;
365 public ushort MaxLocals = 0;
366 public Int32 CodeLength = 0;
367 public byte[] Code;
368 public ushort ExceptionTableLength = 0;
369 public ushort SubAttributeCount = 0;
370 public List<SubAttribute> SubAttributes = new List<SubAttribute>();
371 private ClassRecord parent;
372
373 public MethodAttribute(ClassRecord paren)
374 {
375 parent = paren;
376 }
377
378 public void ReadData(byte[] data, ref int pointer)
379 {
380 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
381 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
382 MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]);
383 MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]);
384 CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
385 Code = new byte[CodeLength];
386 for (int i = 0; i < CodeLength; i++)
387 {
388 Code[i] = data[pointer++];
389 }
390 ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]);
391 SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
392 for (int i = 0; i < SubAttributeCount; i++)
393 {
394 SubAttribute subAttri = new SubAttribute(this.parent);
395 subAttri.ReadData(data, ref pointer);
396 this.SubAttributes.Add(subAttri);
397 }
398 }
399
400 public void Print()
401 {
402 Console.WriteLine("Method Attribute: ");
403 Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
404 Console.WriteLine("Length: " + Length);
405 Console.WriteLine("MaxStack: " + MaxStack);
406 Console.WriteLine("MaxLocals: " + MaxLocals);
407 Console.WriteLine("CodeLength: " + CodeLength);
408 for (int i = 0; i < Code.Length; i++)
409 {
410 Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
411 }
412 Console.WriteLine("SubAttributes: " + SubAttributeCount);
413 for (int i = 0; i < SubAttributeCount; i++)
414 {
415 this.SubAttributes[i].Print();
416 }
417 }
418
419 public class SubAttribute
420 {
421 public ushort NameIndex = 0;
422 public string Name = "";
423 public Int32 Length = 0;
424 public byte[] Data;
425 private ClassRecord parent;
426
427 public SubAttribute(ClassRecord paren)
428 {
429 parent = paren;
430 }
431
432 public void ReadData(byte[] data, ref int pointer)
433 {
434 NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
435 Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
436 Data = new byte[Length];
437 for (int i = 0; i < Length; i++)
438 {
439 Data[i] = data[pointer++];
440 }
441 }
442
443 public void Print()
444 {
445 Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
446 }
447
448 }
449 }
450
451 }
452 private class InterfaceInfo
453 {
454 public void ReadData(byte[] data, ref int i)
455 {
456
457 }
458 }
459 private class FieldInfo
460 {
461 public void ReadData(byte[] data, ref int i)
462 {
463
464 }
465 }
466 private class AttributeInfo
467 {
468 public void ReadData(byte[] data, ref int i)
469 {
470
471 }
472 }
473 #endregion
474
475 }
476}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Heap.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Heap.cs
new file mode 100644
index 0000000..138e85e
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Heap.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 public class Heap
8 {
9 public List<ClassInstance> ClassObjects = new List<ClassInstance>();
10
11 public Heap()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
new file mode 100644
index 0000000..b94248c
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
@@ -0,0 +1,108 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
6
7namespace OpenSim.Scripting.EmbeddedJVM
8{
9 partial class Thread
10 {
11 private partial class Interpreter
12 {
13 private Thread _mThread;
14
15 public Interpreter(Thread parentThread)
16 {
17 _mThread = parentThread;
18 }
19
20 public bool Excute()
21 {
22 bool run = true;
23 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
24 // Console.WriteLine("opCode is: " + currentOpCode);
25 bool handled = false;
26
27 handled = this.IsLogicOpCode(currentOpCode);
28 if (!handled)
29 {
30 handled = this.IsMethodOpCode(currentOpCode);
31 }
32 if (!handled)
33 {
34 if (currentOpCode == 172)
35 {
36 if (this._mThread.stack.StackFrames.Count > 1)
37 {
38 Console.WriteLine("returning int from function");
39 int retPC1 = this._mThread.currentFrame.ReturnPC;
40 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
41 this._mThread.stack.StackFrames.Pop();
42 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
43 this._mThread.PC = retPC1;
44 if (bas1 is Int)
45 {
46 this._mThread.currentFrame.OpStack.Push((Int)bas1);
47 }
48 }
49 else
50 {
51 // Console.WriteLine("No parent function so ending program");
52 this._mThread.stack.StackFrames.Pop();
53 run = false;
54 }
55 handled = true;
56 }
57 if (currentOpCode == 174)
58 {
59 if (this._mThread.stack.StackFrames.Count > 1)
60 {
61 Console.WriteLine("returning float from function");
62 int retPC1 = this._mThread.currentFrame.ReturnPC;
63 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
64 this._mThread.stack.StackFrames.Pop();
65 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
66 this._mThread.PC = retPC1;
67 if (bas1 is Float)
68 {
69 this._mThread.currentFrame.OpStack.Push((Float)bas1);
70 }
71 }
72 else
73 {
74 // Console.WriteLine("No parent function so ending program");
75 this._mThread.stack.StackFrames.Pop();
76 run = false;
77 }
78 handled = true;
79 }
80 if (currentOpCode == 177)
81 {
82 if (this._mThread.stack.StackFrames.Count > 1)
83 {
84 Console.WriteLine("returning from function");
85 int retPC = this._mThread.currentFrame.ReturnPC;
86 this._mThread.stack.StackFrames.Pop();
87 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
88 this._mThread.PC = retPC;
89 }
90 else
91 {
92 // Console.WriteLine("No parent function so ending program");
93 this._mThread.stack.StackFrames.Pop();
94 run = false;
95 }
96 handled = true;
97 }
98 }
99 if (!handled)
100 {
101 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
102 }
103 return run;
104
105 }
106 }
107 }
108}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs
new file mode 100644
index 0000000..3b7da35
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs
@@ -0,0 +1,400 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
6
7namespace OpenSim.Scripting.EmbeddedJVM
8{
9 partial class Thread
10 {
11 private partial class Interpreter
12 {
13 private bool IsLogicOpCode(byte opcode)
14 {
15 bool result = false;
16 switch (opcode)
17 {
18 case 2:
19 Int m_int= new Int();
20 m_int.mValue = -1;
21 this._mThread.currentFrame.OpStack.Push(m_int);
22 result = true;
23 break;
24 case 3:
25 m_int= new Int();
26 m_int.mValue = 0;
27 this._mThread.currentFrame.OpStack.Push(m_int);
28 result = true;
29 break;
30 case 4:
31 m_int = new Int();
32 m_int.mValue = 1;
33 this._mThread.currentFrame.OpStack.Push(m_int);
34 result = true;
35 break;
36 case 5:
37 m_int = new Int();
38 m_int.mValue = 2;
39 this._mThread.currentFrame.OpStack.Push(m_int);
40 result = true;
41 break;
42 case 6:
43 m_int = new Int();
44 m_int.mValue = 3;
45 this._mThread.currentFrame.OpStack.Push(m_int);
46 break;
47 case 7:
48 m_int = new Int();
49 m_int.mValue = 4;
50 this._mThread.currentFrame.OpStack.Push(m_int);
51 result = true;
52 break;
53 case 8:
54 m_int = new Int();
55 m_int.mValue = 5;
56 this._mThread.currentFrame.OpStack.Push(m_int);
57 result = true;
58 break;
59 case 11:
60 Float m_float = new Float();
61 m_float.mValue = 0.0f;
62 this._mThread.currentFrame.OpStack.Push(m_float);
63 result = true;
64 break;
65 case 12:
66 m_float = new Float();
67 m_float.mValue = 1.0f;
68 this._mThread.currentFrame.OpStack.Push(m_float);
69 result = true;
70 break;
71 case 13:
72 m_float = new Float();
73 m_float.mValue = 2.0f;
74 this._mThread.currentFrame.OpStack.Push(m_float);
75 result = true;
76 break;
77 case 16:
78 int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
79 Int pushInt = new Int();
80 pushInt.mValue = pushvalue;
81 this._mThread.currentFrame.OpStack.Push(pushInt);
82 this._mThread.PC++;
83 result = true;
84 break;
85 case 17:
86 short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
87 Int pushInt2 = new Int();
88 pushInt2.mValue = pushvalue2;
89 this._mThread.currentFrame.OpStack.Push(pushInt2);
90 this._mThread.PC += 2;
91 result = true;
92 break;
93 case 23:
94 short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
95 Float fload = new Float();
96 if (this._mThread.currentFrame.LocalVariables[findex1] != null)
97 {
98 if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
99 {
100 fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
101 this._mThread.currentFrame.OpStack.Push(fload);
102 }
103 }
104 this._mThread.PC++;
105 result = true;
106 break;
107 case 26:
108 if (this._mThread.currentFrame.LocalVariables[0] != null)
109 {
110 if (this._mThread.currentFrame.LocalVariables[0] is Int)
111 {
112 Int newInt = new Int();
113 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
114 this._mThread.currentFrame.OpStack.Push(newInt);
115 }
116 }
117 result = true;
118 break;
119 case 27:
120 if (this._mThread.currentFrame.LocalVariables[1] != null)
121 {
122 if (this._mThread.currentFrame.LocalVariables[1] is Int)
123 {
124 Int newInt = new Int();
125 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
126 this._mThread.currentFrame.OpStack.Push(newInt);
127 }
128 }
129 result = true;
130 break;
131 case 34:
132 if (this._mThread.currentFrame.LocalVariables[0] != null)
133 {
134 if (this._mThread.currentFrame.LocalVariables[0] is Float)
135 {
136 Float newfloat = new Float();
137 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
138 this._mThread.currentFrame.OpStack.Push(newfloat);
139 }
140 }
141 result = true;
142 break;
143 case 35:
144 if (this._mThread.currentFrame.LocalVariables[1] != null)
145 {
146 if (this._mThread.currentFrame.LocalVariables[1] is Float)
147 {
148 Float newfloat = new Float();
149 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
150 this._mThread.currentFrame.OpStack.Push(newfloat);
151 }
152 }
153 result = true;
154 break;
155 case 36:
156 if (this._mThread.currentFrame.LocalVariables[2] != null)
157 {
158 if (this._mThread.currentFrame.LocalVariables[2] is Float)
159 {
160 Float newfloat = new Float();
161 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
162 this._mThread.currentFrame.OpStack.Push(newfloat);
163 }
164 }
165 result = true;
166 break;
167 case 37:
168 if (this._mThread.currentFrame.LocalVariables[3] != null)
169 {
170 if (this._mThread.currentFrame.LocalVariables[3] is Float)
171 {
172 Float newfloat = new Float();
173 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
174 this._mThread.currentFrame.OpStack.Push(newfloat);
175 }
176 }
177 result = true;
178 break;
179 case 56:
180 short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
181 BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
182 if (fstor is Float)
183 {
184 this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
185 }
186 this._mThread.PC++;
187 result = true;
188 break;
189 case 59:
190 BaseType baset = this._mThread.currentFrame.OpStack.Pop();
191 if (baset is Int)
192 {
193 this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
194 }
195 result = true;
196 break;
197 case 60:
198 baset = this._mThread.currentFrame.OpStack.Pop();
199 if (baset is Int)
200 {
201 this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
202 }
203 result = true;
204 break;
205 case 67:
206 baset = this._mThread.currentFrame.OpStack.Pop();
207 if (baset is Float)
208 {
209 this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
210 }
211 result = true;
212 break;
213 case 68:
214 baset = this._mThread.currentFrame.OpStack.Pop();
215 if (baset is Float)
216 {
217 this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
218 }
219 result = true;
220 break;
221 case 69:
222 baset = this._mThread.currentFrame.OpStack.Pop();
223 if (baset is Float)
224 {
225 this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
226 }
227 result = true;
228 break;
229 case 70:
230 baset = this._mThread.currentFrame.OpStack.Pop();
231 if (baset is Float)
232 {
233 this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
234 }
235 result = true;
236 break;
237 case 87:
238 this._mThread.currentFrame.OpStack.Pop();
239 result = true;
240 break;
241 case 98:
242 BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
243 BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
244 if (bf1 is Float && bf2 is Float)
245 {
246 Float nflt = new Float();
247 nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
248 this._mThread.currentFrame.OpStack.Push(nflt);
249 }
250 result = true;
251 break;
252 case 102:
253 BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
254 BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
255 if (bsf1 is Float && bsf2 is Float)
256 {
257 Float resf = new Float();
258 resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
259 this._mThread.currentFrame.OpStack.Push(resf);
260 }
261 result = true;
262 break;
263 case 104: //check the order of the two values off the stack is correct
264 BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
265 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
266 if (bs1 is Int && bs2 is Int)
267 {
268 Int nInt = new Int();
269 nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
270 this._mThread.currentFrame.OpStack.Push(nInt);
271 }
272 result = true;
273 break;
274 case 132:
275 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
276 {
277 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
278 {
279 ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
280 }
281 }
282 this._mThread.PC += 2;
283 result = true;
284 break;
285 case 139:
286 BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
287 if (conv1 is Float)
288 {
289 Int newconv = new Int();
290 newconv.mValue = (int)((Float)conv1).mValue;
291 this._mThread.currentFrame.OpStack.Push(newconv);
292 }
293 result = true;
294 break;
295 case 149:
296 BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
297 BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
298 if (flcom1 is Float && flcom2 is Float)
299 {
300 Int compres = new Int();
301 if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
302 {
303 compres.mValue = -1;
304 }
305 else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
306 {
307 compres.mValue = 1;
308 }
309 else
310 {
311 compres.mValue = 0;
312 }
313 this._mThread.currentFrame.OpStack.Push(compres);
314 }
315 result = true;
316 break;
317 case 158:
318 short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
319 BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
320 if (comp1 is Int)
321 {
322 if (((Int)comp1).mValue <= 0)
323 {
324 this._mThread.PC += -1 + compareoffset1;
325 }
326 else
327 {
328 this._mThread.PC += 2;
329 }
330 }
331 else
332 {
333 this._mThread.PC += 2;
334 }
335 result = true;
336 break;
337 case 162:
338 short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
339 BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
340 BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
341 if (bc1 is Int && bc2 is Int)
342 {
343 //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
344 if (((Int)bc1).mValue >= ((Int)bc2).mValue)
345 {
346 // Console.WriteLine("branch compare true , offset is " +compareoffset);
347 // Console.WriteLine("current PC is " + this._mThread.PC);
348 this._mThread.PC += -1 + compareoffset;
349 //Console.WriteLine("new PC is " + this._mThread.PC);
350 }
351 else
352 {
353 //Console.WriteLine("branch compare false");
354 this._mThread.PC += 2;
355 }
356 }
357 else
358 {
359 this._mThread.PC += 2;
360 }
361 result = true;
362 break;
363 case 164:
364 short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
365 BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
366 BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
367 if (bcl1 is Int && bcl2 is Int)
368 {
369 //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
370 if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
371 {
372 // Console.WriteLine("branch compare true , offset is " + compareloffset);
373 // Console.WriteLine("current PC is " + this._mThread.PC);
374 this._mThread.PC += -1 + compareloffset;
375 // Console.WriteLine("new PC is " + this._mThread.PC);
376 }
377 else
378 {
379 //Console.WriteLine("branch compare false");
380 this._mThread.PC += 2;
381 }
382 }
383 else
384 {
385 this._mThread.PC += 2;
386 }
387 result = true;
388 break;
389 case 167:
390 short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
391 this._mThread.PC += -1 + offset;
392 result = true;
393 break;
394 }
395
396 return result;
397 }
398 }
399 }
400}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs
new file mode 100644
index 0000000..c66c148
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs
@@ -0,0 +1,141 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework;
8using OpenSim.Framework.Types;
9
10namespace OpenSim.Scripting.EmbeddedJVM
11{
12 partial class Thread
13 {
14 private partial class Interpreter
15 {
16 private bool IsMethodOpCode(byte opcode)
17 {
18 bool result = false;
19 switch (opcode)
20 {
21 case 184:
22 short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
23 //Console.WriteLine("call to method : "+refIndex);
24 if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
25 {
26 // Console.WriteLine("which is " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value + "." + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value);
27 // Console.WriteLine("of type " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value);
28 string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value;
29 string typeparam = "";
30 string typereturn = "";
31 int firstbrak = 0;
32 int secondbrak = 0;
33 firstbrak = typ.LastIndexOf('(');
34 secondbrak = typ.LastIndexOf(')');
35 typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
36 typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
37 //Console.WriteLine("split is " + typeparam + " which is length " + typeparam.Length + " , " + typereturn);
38 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
39 {
40 //calling a method in this class
41 if (typeparam.Length == 0)
42 {
43 this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2));
44 }
45 else
46 {
47 this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2));
48 }
49 }
50 else
51 {
52 //calling a method of a different class
53
54 //for now we will have a built in OpenSimAPI class, but this should be a java class that then calls native methods
55 if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
56 {
57 switch (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value)
58 {
59 case "GetEntityID":
60 Int entityID = new Int();
61 entityID.mValue =(int) this._mThread.EntityId;
62 this._mThread.currentFrame.OpStack.Push(entityID);
63 this._mThread.PC += 2;
64 break;
65 case "GetRandomAvatarID":
66 entityID = new Int();
67 entityID.mValue = (int)Thread.OpenSimScriptAPI.GetRandomAvatarID();
68 this._mThread.currentFrame.OpStack.Push(entityID);
69 this._mThread.PC += 2;
70 break;
71 case "GetEntityPositionX":
72 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
73 if (bs1 is Int)
74 {
75 //Console.WriteLine("get entity pos for " + ((Int)bs1).mValue);
76 //should get the position of the entity from the IScriptAPI
77 OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue);
78 Float pos = new Float();
79 pos.mValue = vec3.X;
80 // Console.WriteLine("returned x value " + vec3.X.ToString());
81 this._mThread.currentFrame.OpStack.Push(pos);
82 }
83 this._mThread.PC += 2;
84 break;
85 case "GetEntityPositionY":
86 bs1 = this._mThread.currentFrame.OpStack.Pop();
87 if (bs1 is Int)
88 {
89 //should get the position of the entity from the IScriptAPI
90 OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue);
91 Float pos = new Float();
92 pos.mValue = vec3.Y;
93 this._mThread.currentFrame.OpStack.Push(pos);
94 }
95 this._mThread.PC += 2;
96 break;
97 case "GetEntityPositionZ":
98 bs1 = this._mThread.currentFrame.OpStack.Pop();
99 if (bs1 is Int)
100 {
101 //should get the position of the entity from the IScriptAPI
102 OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue);
103 Float pos = new Float();
104 pos.mValue = vec3.Z;
105 this._mThread.currentFrame.OpStack.Push(pos);
106 }
107 this._mThread.PC += 2;
108 break;
109 case "SetEntityPosition":
110 //pop the three float values and the entity id
111 BaseType ft3 = this._mThread.currentFrame.OpStack.Pop();
112 BaseType ft2 = this._mThread.currentFrame.OpStack.Pop();
113 BaseType ft1 = this._mThread.currentFrame.OpStack.Pop();
114 BaseType in1 = this._mThread.currentFrame.OpStack.Pop();
115 if (ft1 is Float && ft2 is Float && ft3 is Float)
116 {
117 if(in1 is Int)
118 {
119 //Console.WriteLine("set: " + ((Int)in1).mValue + " , " + ((Float)ft1).mValue + " , " + ((Float)ft2).mValue + " , " + ((Float)ft3).mValue);
120 Thread.OpenSimScriptAPI.SetEntityPosition((uint)((Int) in1).mValue, ((Float)ft1).mValue, ((Float)ft2).mValue, ((Float)ft3).mValue);
121 }
122 }
123 this._mThread.PC += 2;
124 break;
125 }
126 }
127 }
128 }
129 else
130 {
131 this._mThread.PC += 2;
132 }
133 result = true;
134 break;
135 }
136
137 return result;
138 }
139 }
140 }
141}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs
new file mode 100644
index 0000000..6704e31
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs
@@ -0,0 +1,13 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 partial class Thread
8 {
9 private partial class Interpreter
10 {
11 }
12 }
13}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs
new file mode 100644
index 0000000..ff18f90
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 public class MainMemory
8 {
9 public Heap HeapArea;
10 public MethodMemory MethodArea;
11
12 public MainMemory()
13 {
14 MethodArea = new MethodMemory();
15 HeapArea = new Heap();
16 }
17 }
18}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs
new file mode 100644
index 0000000..2541991
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 public class MethodMemory
8 {
9 public byte[] MethodBuffer;
10 public List<ClassRecord> Classes = new List<ClassRecord>();
11 public int NextMethodPC = 0;
12 public int Methodcount = 0;
13
14 public MethodMemory()
15 {
16 MethodBuffer = new byte[20000];
17 }
18 }
19}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Object.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Object.cs
new file mode 100644
index 0000000..e6e392c
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Object.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 public class Object
8 {
9 }
10}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj
new file mode 100644
index 0000000..bd1a332
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj
@@ -0,0 +1,153 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{97A82740-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Scripting.EmbeddedJVM</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Scripting.EmbeddedJVM</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\ScriptEngines\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\ScriptEngines\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 </ItemGroup>
70 <ItemGroup>
71 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
72 <Name>OpenSim.Framework</Name>
73 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
74 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
75 <Private>False</Private>
76 </ProjectReference>
77 </ItemGroup>
78 <ItemGroup>
79 <Compile Include="ClassInstance.cs">
80 <SubType>Code</SubType>
81 </Compile>
82 <Compile Include="ClassRecord.cs">
83 <SubType>Code</SubType>
84 </Compile>
85 <Compile Include="Heap.cs">
86 <SubType>Code</SubType>
87 </Compile>
88 <Compile Include="Interpreter.cs">
89 <SubType>Code</SubType>
90 </Compile>
91 <Compile Include="InterpreterLogic.cs">
92 <SubType>Code</SubType>
93 </Compile>
94 <Compile Include="InterpreterMethods.cs">
95 <SubType>Code</SubType>
96 </Compile>
97 <Compile Include="InterpreterReturn.cs">
98 <SubType>Code</SubType>
99 </Compile>
100 <Compile Include="MainMemory.cs">
101 <SubType>Code</SubType>
102 </Compile>
103 <Compile Include="MethodMemory.cs">
104 <SubType>Code</SubType>
105 </Compile>
106 <Compile Include="Object.cs">
107 <SubType>Code</SubType>
108 </Compile>
109 <Compile Include="OpenSimJVM.cs">
110 <SubType>Code</SubType>
111 </Compile>
112 <Compile Include="Stack.cs">
113 <SubType>Code</SubType>
114 </Compile>
115 <Compile Include="StackFrame.cs">
116 <SubType>Code</SubType>
117 </Compile>
118 <Compile Include="Thread.cs">
119 <SubType>Code</SubType>
120 </Compile>
121 <Compile Include="Properties\AssemblyInfo.cs">
122 <SubType>Code</SubType>
123 </Compile>
124 <Compile Include="Types\ArrayReference.cs">
125 <SubType>Code</SubType>
126 </Compile>
127 <Compile Include="Types\BaseType.cs">
128 <SubType>Code</SubType>
129 </Compile>
130 <Compile Include="Types\ObjectReference.cs">
131 <SubType>Code</SubType>
132 </Compile>
133 <Compile Include="Types\PrimitiveTypes\Byte.cs">
134 <SubType>Code</SubType>
135 </Compile>
136 <Compile Include="Types\PrimitiveTypes\Char.cs">
137 <SubType>Code</SubType>
138 </Compile>
139 <Compile Include="Types\PrimitiveTypes\Float.cs">
140 <SubType>Code</SubType>
141 </Compile>
142 <Compile Include="Types\PrimitiveTypes\Int.cs">
143 <SubType>Code</SubType>
144 </Compile>
145 </ItemGroup>
146 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
147 <PropertyGroup>
148 <PreBuildEvent>
149 </PreBuildEvent>
150 <PostBuildEvent>
151 </PostBuildEvent>
152 </PropertyGroup>
153</Project>
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build
new file mode 100644
index 0000000..c5255db
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build
@@ -0,0 +1,62 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Scripting.EmbeddedJVM" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Scripting.EmbeddedJVM" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="ClassInstance.cs" />
15 <include name="ClassRecord.cs" />
16 <include name="Heap.cs" />
17 <include name="Interpreter.cs" />
18 <include name="InterpreterLogic.cs" />
19 <include name="InterpreterMethods.cs" />
20 <include name="InterpreterReturn.cs" />
21 <include name="MainMemory.cs" />
22 <include name="MethodMemory.cs" />
23 <include name="Object.cs" />
24 <include name="OpenSimJVM.cs" />
25 <include name="Stack.cs" />
26 <include name="StackFrame.cs" />
27 <include name="Thread.cs" />
28 <include name="Properties/AssemblyInfo.cs" />
29 <include name="Types/ArrayReference.cs" />
30 <include name="Types/BaseType.cs" />
31 <include name="Types/ObjectReference.cs" />
32 <include name="Types/PrimitiveTypes/Byte.cs" />
33 <include name="Types/PrimitiveTypes/Char.cs" />
34 <include name="Types/PrimitiveTypes/Float.cs" />
35 <include name="Types/PrimitiveTypes/Int.cs" />
36 </sources>
37 <references basedir="${project::get-base-directory()}">
38 <lib>
39 <include name="${project::get-base-directory()}" />
40 <include name="${project::get-base-directory()}/${build.dir}" />
41 </lib>
42 <include name="System.dll" />
43 <include name="System.Xml.dll" />
44 <include name="../../../bin/OpenSim.Framework.dll" />
45 </references>
46 </csc>
47 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/ScriptEngines/" />
48 <mkdir dir="${project::get-base-directory()}/../../../bin/ScriptEngines/"/>
49 <copy todir="${project::get-base-directory()}/../../../bin/ScriptEngines/">
50 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
51 <include name="*.dll"/>
52 <include name="*.exe"/>
53 </fileset>
54 </copy>
55 </target>
56 <target name="clean">
57 <delete dir="${bin.dir}" failonerror="false" />
58 <delete dir="${obj.dir}" failonerror="false" />
59 </target>
60 <target name="doc" description="Creates documentation.">
61 </target>
62</project>
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs
new file mode 100644
index 0000000..b47bb50
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs
@@ -0,0 +1,134 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Threading;
6using OpenSim.Framework;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Utilities;
9
10namespace OpenSim.Scripting.EmbeddedJVM
11{
12 public class OpenSimJVM : IScriptEngine
13 {
14 private List<Thread> _threads = new List<Thread>();
15 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
16 private MainMemory _mainMemory;
17 private System.Threading.Thread compileThread;
18
19 public OpenSimJVM()
20 {
21
22 }
23
24 public bool Init(IScriptAPI api)
25 {
26 Console.WriteLine("Creating OpenSim JVM scripting engine");
27 _mainMemory = new MainMemory();
28 Thread.GlobalMemory = this._mainMemory;
29 Thread.OpenSimScriptAPI = api;
30 compileThread = new System.Threading.Thread(new ThreadStart(CompileScript));
31 compileThread.IsBackground = true;
32 compileThread.Start();
33 return true;
34 }
35
36 public string GetName()
37 {
38 return "OpenSimJVM";
39 }
40
41 public void LoadScript(string script, string scriptName, uint entityID)
42 {
43 Console.WriteLine("OpenSimJVM - loading new script: " + scriptName);
44 CompileInfo comp = new CompileInfo();
45 comp.entityId = entityID;
46 comp.script = script;
47 comp.scriptName = scriptName;
48 this.CompileScripts.Enqueue(comp);
49 }
50
51 public void CompileScript()
52 {
53 while (true)
54 {
55 CompileInfo comp = this.CompileScripts.Dequeue();
56 string script = comp.script;
57 string scriptName = comp.scriptName;
58 uint entityID = comp.entityId;
59 try
60 {
61 //need to compile the script into a java class file
62
63 //first save it to a java source file
64 TextWriter tw = new StreamWriter(scriptName + ".java");
65 tw.WriteLine(script);
66 tw.Close();
67
68 //now compile
69 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
70 // psi.RedirectStandardOutput = true;
71 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
72 psi.UseShellExecute = false;
73
74 System.Diagnostics.Process javacomp;
75 javacomp = System.Diagnostics.Process.Start(psi);
76 javacomp.WaitForExit();
77
78
79 //now load in class file
80 ClassRecord class1 = new ClassRecord();
81 class1.LoadClassFromFile(scriptName + ".class");
82 class1.PrintToConsole();
83 //Console.WriteLine();
84 this._mainMemory.MethodArea.Classes.Add(class1);
85 class1.AddMethodsToMemory(this._mainMemory.MethodArea);
86
87 Thread newThread = new Thread();
88 this._threads.Add(newThread);
89 newThread.EntityId = entityID;
90 newThread.currentClass = class1;
91
92 //now delete the created files
93 System.IO.File.Delete(scriptName + ".java");
94 System.IO.File.Delete(scriptName + ".class");
95 //this.OnFrame();
96 }
97 catch (Exception e)
98 {
99 Console.WriteLine("exception");
100 Console.WriteLine(e.StackTrace);
101 Console.WriteLine(e.Message);
102 }
103 }
104 }
105
106 public void OnFrame()
107 {
108 for (int i = 0; i < this._threads.Count; i++)
109 {
110 if (!this._threads[i].running)
111 {
112 this._threads[i].StartMethod("OnFrame");
113 bool run = true;
114 while (run)
115 {
116 run = this._threads[i].Excute();
117 }
118 }
119 }
120 }
121
122 private class CompileInfo
123 {
124 public string script;
125 public string scriptName;
126 public uint entityId;
127
128 public CompileInfo()
129 {
130
131 }
132 }
133 }
134}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..53a0f08
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Scripting.EmbeddedJVM")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Scripting.EmbeddedJVM")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("087c0917-5a6a-4b47-a4dd-0928dd85bd4b")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Stack.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Stack.cs
new file mode 100644
index 0000000..d77d82e
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Stack.cs
@@ -0,0 +1,15 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM
6{
7 public class Stack
8 {
9 public Stack<StackFrame> StackFrames = new Stack<StackFrame>();
10
11 public Stack()
12 {
13 }
14 }
15}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs
new file mode 100644
index 0000000..afca7a9
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5
6namespace OpenSim.Scripting.EmbeddedJVM
7{
8 public class StackFrame
9 {
10 public BaseType[] LocalVariables;
11 public Stack<BaseType> OpStack = new Stack<BaseType>();
12
13 public int ReturnPC = 0;
14 public ClassRecord CallingClass = null;
15
16 public StackFrame()
17 {
18 LocalVariables = new BaseType[20];
19 }
20
21 }
22}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Thread.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Thread.cs
new file mode 100644
index 0000000..436949c
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Thread.cs
@@ -0,0 +1,88 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Scripting.EmbeddedJVM.Types;
5using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
6using OpenSim.Framework;
7using OpenSim.Framework.Interfaces;
8
9namespace OpenSim.Scripting.EmbeddedJVM
10{
11 public partial class Thread
12 {
13 public static MainMemory GlobalMemory;
14 public static IScriptAPI OpenSimScriptAPI;
15 private int PC = 0;
16 private Stack stack;
17 private Interpreter mInterpreter;
18 public ClassRecord currentClass;
19 public ClassInstance currentInstance;
20 private StackFrame currentFrame;
21 public int excutionCounter = 0;
22 public bool running = false;
23 public uint EntityId = 0;
24
25 public Thread()
26 {
27 this.mInterpreter = new Interpreter(this);
28 this.stack = new Stack();
29 }
30
31 public void SetPC(int methodpointer)
32 {
33 //Console.WriteLine("Thread PC has been set to " + methodpointer);
34 PC = methodpointer;
35 }
36
37 public void StartMethod(ClassRecord rec, string methName)
38 {
39 currentFrame = new StackFrame();
40 this.stack.StackFrames.Push(currentFrame);
41 this.currentClass = rec;
42 currentClass.StartMethod(this, methName);
43 }
44
45 public void StartMethod( string methName)
46 {
47 currentFrame = new StackFrame();
48 this.stack.StackFrames.Push(currentFrame);
49 currentClass.StartMethod(this, methName);
50 }
51
52 public void JumpToStaticVoidMethod(string methName, int returnPC)
53 {
54 currentFrame = new StackFrame();
55 currentFrame.ReturnPC = returnPC;
56 this.stack.StackFrames.Push(currentFrame);
57 currentClass.StartMethod(this, methName);
58 }
59
60 public void JumpToStaticParamMethod(string methName, string param, int returnPC)
61 {
62 if (param == "I")
63 {
64 BaseType bs1 = currentFrame.OpStack.Pop();
65 currentFrame = new StackFrame();
66 currentFrame.ReturnPC = returnPC;
67 this.stack.StackFrames.Push(currentFrame);
68 currentFrame.LocalVariables[0] = ((Int)bs1);
69 currentClass.StartMethod(this, methName);
70 }
71 if (param == "F")
72 {
73
74 }
75 }
76
77 public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
78 {
79
80 }
81
82 public bool Excute()
83 {
84 excutionCounter++;
85 return this.mInterpreter.Excute();
86 }
87 }
88}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs
new file mode 100644
index 0000000..2854eab
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class ArrayReference :BaseType
8 {
9 }
10}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs
new file mode 100644
index 0000000..270aa7b
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class BaseType : Object
8 {
9 }
10}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs
new file mode 100644
index 0000000..da28eaa
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types
6{
7 public class ObjectReference : BaseType
8 {
9 public ushort Reference;
10
11 public ObjectReference()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs
new file mode 100644
index 0000000..1a3ecff
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Byte : BaseType
8 {
9 }
10}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs
new file mode 100644
index 0000000..19002d4
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Char : BaseType
8 {
9 }
10}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs
new file mode 100644
index 0000000..91f1679
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Float : BaseType
8 {
9 public float mValue = 0;
10
11 public Float()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs
new file mode 100644
index 0000000..4ecd325
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
6{
7 public class Int : BaseType
8 {
9 public int mValue = 0;
10
11 public Int()
12 {
13
14 }
15 }
16}
diff --git a/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
new file mode 100644
index 0000000..d4db8c0
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs
@@ -0,0 +1,95 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28// BDB Support
29// Apparently broken on Mono
30
31using System;
32using System.Collections.Generic;
33using System.Data;
34using libsecondlife;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Terrain;
38using BerkeleyDb;
39using Kds.Serialization;
40using Kds.Serialization.Buffer;
41
42namespace OpenSim.Storage.LocalStorageBDB
43{
44 public class BDBLocalStorage : ILocalStorage
45 {
46 const string simDbName = "localsim.db";
47
48 DbHash sim;
49 Db DB;
50 //BEFormatter formatter;
51
52 public BDBLocalStorage()
53 {
54 DB = new Db(DbCreateFlags.None);
55 sim = (DbHash)DB.Open(null, simDbName, null, BerkeleyDb.DbType.Hash, Db.OpenFlags.Create, 0);
56 //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0);
57 }
58
59 public void Initialise(string file)
60 {
61 // Blank
62 }
63
64 public void StorePrim(PrimData prim)
65 {
66 DbEntry key = new DbEntry();
67 DbEntry data = new DbEntry();
68 lock (sim)
69 {
70 sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit);
71 }
72 }
73 public void RemovePrim(LLUUID primID)
74 {
75
76 }
77 public void LoadPrimitives(ILocalStorageReceiver receiver)
78 {
79
80 }
81 public float[] LoadWorld()
82 {
83 return new float[65536];
84 }
85 public void SaveMap(float[] heightmap)
86 {
87
88 }
89 public void ShutDown()
90 {
91 sim.GetDb().Close();
92 DB.Close();
93 }
94 }
95} \ No newline at end of file
diff --git a/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj
new file mode 100644
index 0000000..e615bc5
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj
@@ -0,0 +1,112 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{EE9E5D96-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Storage.LocalStorageBerkeleyDB</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Storage.LocalStorageBerkeleyDB</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Kds.Serialization.dll" >
74 <HintPath>..\..\..\bin\Kds.Serialization.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="libdb_dotNET43.dll" >
78 <HintPath>..\..\..\bin\libdb_dotNET43.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="libsecondlife.dll" >
82 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
94 <Name>OpenSim.Framework.Console</Name>
95 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 </ItemGroup>
100 <ItemGroup>
101 <Compile Include="BDBLocalStorage.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 </ItemGroup>
105 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
106 <PropertyGroup>
107 <PreBuildEvent>
108 </PreBuildEvent>
109 <PostBuildEvent>
110 </PostBuildEvent>
111 </PropertyGroup>
112</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build
new file mode 100644
index 0000000..1c7306a
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Storage.LocalStorageBerkeleyDB" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Storage.LocalStorageBerkeleyDB" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="BDBLocalStorage.cs" />
15 </sources>
16 <references basedir="${project::get-base-directory()}">
17 <lib>
18 <include name="${project::get-base-directory()}" />
19 <include name="${project::get-base-directory()}/${build.dir}" />
20 </lib>
21 <include name="System.dll" />
22 <include name="System.Xml.dll" />
23 <include name="System.Data.dll" />
24 <include name="../../../bin/Kds.Serialization.dll" />
25 <include name="../../../bin/libdb_dotNET43.dll" />
26 <include name="../../../bin/libsecondlife.dll" />
27 <include name="../../../bin/OpenSim.Framework.dll" />
28 <include name="../../../bin/OpenSim.Framework.Console.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs
new file mode 100644
index 0000000..6610606
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("Db4LocalStorage")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("Db4LocalStorage")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
new file mode 100644
index 0000000..5dceb7f
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -0,0 +1,182 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using Db4objects.Db4o;
30using Db4objects.Db4o.Query;
31using libsecondlife;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34using OpenSim.Framework.Terrain;
35
36namespace OpenSim.Storage.LocalStorageDb4o
37{
38 /// <summary>
39 ///
40 /// </summary>
41 public class Db4LocalStorage : ILocalStorage
42 {
43 private IObjectContainer db;
44 private string datastore;
45
46 public Db4LocalStorage()
47 {
48
49 }
50
51 public void Initialise(string dfile)
52 {
53 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Db4LocalStorage Opening " + dfile);
54 datastore = dfile;
55 try
56 {
57 db = Db4oFactory.OpenFile(datastore);
58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Db4LocalStorage creation");
59 }
60 catch (Exception e)
61 {
62 db.Close();
63 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Db4LocalStorage :Constructor - Exception occured");
64 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
65 }
66 }
67
68 public void StorePrim(PrimData prim)
69 {
70 IObjectSet result = db.Query(new UUIDQuery(prim.FullID));
71 if(result.Count>0)
72 {
73 //prim already in storage
74 //so update it
75 PrimData found = (PrimData) result.Next();
76 found.PathBegin = prim.PathBegin;
77 found.PathCurve= prim.PathCurve;
78 found.PathEnd = prim.PathEnd;
79 found.PathRadiusOffset = prim.PathRadiusOffset;
80 found.PathRevolutions = prim.PathRevolutions;
81 found.PathScaleX= prim.PathScaleX;
82 found.PathScaleY = prim.PathScaleY;
83 found.PathShearX = prim.PathShearX;
84 found.PathShearY = prim.PathShearY;
85 found.PathSkew = prim.PathSkew;
86 found.PathTaperX = prim.PathTaperX;
87 found.PathTaperY = prim.PathTaperY;
88 found.PathTwist = prim.PathTwist;
89 found.PathTwistBegin = prim.PathTwistBegin;
90 found.PCode = prim.PCode;
91 found.ProfileBegin = prim.ProfileBegin;
92 found.ProfileCurve = prim.ProfileCurve;
93 found.ProfileEnd = prim.ProfileEnd;
94 found.ProfileHollow = prim.ProfileHollow;
95 found.Position = prim.Position;
96 found.Rotation = prim.Rotation;
97 found.Texture = prim.Texture;
98 db.Set(found);
99 db.Commit();
100 }
101 else
102 {
103 //not in storage
104 db.Set(prim);
105 db.Commit();
106 }
107 }
108
109 public void RemovePrim(LLUUID primID)
110 {
111 IObjectSet result = db.Query(new UUIDQuery(primID));
112 if(result.Count>0)
113 {
114 PrimData found = (PrimData) result.Next();
115 db.Delete(found);
116 }
117 }
118
119
120 public void LoadPrimitives(ILocalStorageReceiver receiver)
121 {
122 IObjectSet result = db.Get(typeof(PrimData));
123 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count);
124 foreach (PrimData prim in result) {
125 receiver.PrimFromStorage(prim);
126 }
127 }
128
129 public float[] LoadWorld()
130 {
131 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"LoadWorld() - Loading world....");
132 //World blank = new World();
133 float[] heightmap = null;
134 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"LoadWorld() - Looking for a heightmap in local DB");
135 IObjectSet world_result = db.Get(typeof(MapStorage));
136 if (world_result.Count > 0)
137 {
138 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"LoadWorld() - Found a heightmap in local database, loading");
139 MapStorage map = (MapStorage)world_result.Next();
140 //blank.LandMap = map.Map;
141 heightmap = map.Map;
142 }
143 else
144 {
145 /*
146 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - No heightmap found, generating new one");
147 HeightmapGenHills hills = new HeightmapGenHills();
148 // blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
149 // heightmap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
150 heightmap = new float[256, 256];
151 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Saving heightmap to local database");
152 MapStorage map = new MapStorage();
153 map.Map = heightmap; //blank.LandMap;
154 db.Set(map);
155 db.Commit();
156 */
157 }
158 return heightmap;
159 }
160
161 public void SaveMap(float[] heightmap)
162 {
163 IObjectSet world_result = db.Get(typeof(MapStorage));
164 if (world_result.Count > 0)
165 {
166 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"SaveWorld() - updating saved copy of heightmap in local database");
167 MapStorage map = (MapStorage)world_result.Next();
168 db.Delete(map);
169 }
170 MapStorage map1 = new MapStorage();
171 map1.Map = heightmap; //OpenSim_Main.local_world.LandMap;
172 db.Set(map1);
173 db.Commit();
174 }
175
176 public void ShutDown()
177 {
178 db.Commit();
179 db.Close();
180 }
181 }
182}
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
new file mode 100644
index 0000000..db590ff
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Storage.LocalStorageDb4o
6{
7 public class MapStorage
8 {
9 public float[] Map;
10
11 public MapStorage()
12 {
13
14 }
15 }
16} \ No newline at end of file
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj
new file mode 100644
index 0000000..9b4ff5d
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj
@@ -0,0 +1,113 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{E1B79ECF-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Storage.LocalStorageDb4o</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Storage.LocalStorageDb4o</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="Db4objects.Db4o.dll" >
70 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="libsecondlife.dll" >
74 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="AssemblyInfo.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="Db4LocalStorage.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="MapStorage.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 <Compile Include="UUIDQuery.cs">
103 <SubType>Code</SubType>
104 </Compile>
105 </ItemGroup>
106 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
107 <PropertyGroup>
108 <PreBuildEvent>
109 </PreBuildEvent>
110 <PostBuildEvent>
111 </PostBuildEvent>
112 </PropertyGroup>
113</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build
new file mode 100644
index 0000000..da2db14
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/OpenSim.Storage.LocalStorageDb4o.dll.build
@@ -0,0 +1,47 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Storage.LocalStorageDb4o" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Storage.LocalStorageDb4o" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="Db4LocalStorage.cs" />
16 <include name="MapStorage.cs" />
17 <include name="UUIDQuery.cs" />
18 </sources>
19 <references basedir="${project::get-base-directory()}">
20 <lib>
21 <include name="${project::get-base-directory()}" />
22 <include name="${project::get-base-directory()}/${build.dir}" />
23 </lib>
24 <include name="System.dll" />
25 <include name="System.Xml.dll" />
26 <include name="../../../bin/Db4objects.Db4o.dll" />
27 <include name="../../../bin/libsecondlife.dll" />
28 <include name="../../../bin/OpenSim.Framework.dll" />
29 <include name="../../../bin/OpenSim.Framework.Console.dll" />
30 </references>
31 </csc>
32 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
33 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
34 <copy todir="${project::get-base-directory()}/../../../bin/">
35 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
36 <include name="*.dll"/>
37 <include name="*.exe"/>
38 </fileset>
39 </copy>
40 </target>
41 <target name="clean">
42 <delete dir="${bin.dir}" failonerror="false" />
43 <delete dir="${obj.dir}" failonerror="false" />
44 </target>
45 <target name="doc" description="Creates documentation.">
46 </target>
47</project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs b/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs
new file mode 100644
index 0000000..ba9e139
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageDb4o/UUIDQuery.cs
@@ -0,0 +1,25 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Db4objects.Db4o;
5using Db4objects.Db4o.Query;
6using libsecondlife;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9
10namespace OpenSim.Storage.LocalStorageDb4o
11{
12 public class UUIDQuery : Predicate
13 {
14 private LLUUID _findID;
15
16 public UUIDQuery(LLUUID find)
17 {
18 _findID = find;
19 }
20 public bool Match(PrimData prim)
21 {
22 return (prim.FullID == _findID);
23 }
24 }
25}
diff --git a/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj
new file mode 100644
index 0000000..08ac690
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj
@@ -0,0 +1,111 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{6B20B603-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Storage.LocalStorageSQLite</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Storage.LocalStorageSQLite</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Data.SQLite.dll" >
74 <HintPath>..\..\..\bin\System.Data.SQLite.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="libsecondlife.dll" >
78 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
84 <Name>OpenSim.Framework</Name>
85 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
90 <Name>OpenSim.Framework.Console</Name>
91 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 </ItemGroup>
96 <ItemGroup>
97 <Compile Include="SQLiteLocalStorage.cs">
98 <SubType>Code</SubType>
99 </Compile>
100 <Compile Include="Properties\AssemblyInfo.cs">
101 <SubType>Code</SubType>
102 </Compile>
103 </ItemGroup>
104 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
105 <PropertyGroup>
106 <PreBuildEvent>
107 </PreBuildEvent>
108 <PostBuildEvent>
109 </PostBuildEvent>
110 </PropertyGroup>
111</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build
new file mode 100644
index 0000000..4c8917a
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build
@@ -0,0 +1,46 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Storage.LocalStorageSQLite" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Storage.LocalStorageSQLite" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="SQLiteLocalStorage.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="System.Xml.dll" />
24 <include name="System.Data.dll" />
25 <include name="../../../bin/System.Data.SQLite.dll" />
26 <include name="../../../bin/libsecondlife.dll" />
27 <include name="../../../bin/OpenSim.Framework.dll" />
28 <include name="../../../bin/OpenSim.Framework.Console.dll" />
29 </references>
30 </csc>
31 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
32 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
33 <copy todir="${project::get-base-directory()}/../../../bin/">
34 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
35 <include name="*.dll"/>
36 <include name="*.exe"/>
37 </fileset>
38 </copy>
39 </target>
40 <target name="clean">
41 <delete dir="${bin.dir}" failonerror="false" />
42 <delete dir="${obj.dir}" failonerror="false" />
43 </target>
44 <target name="doc" description="Creates documentation.">
45 </target>
46</project>
diff --git a/OpenSim/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..fe81f8a
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Storage.LocalStorageSQLite")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Storage.LocalStorageSQLite")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.*")]
35[assembly: AssemblyFileVersion("1.0.0.*")]
diff --git a/OpenSim/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
new file mode 100644
index 0000000..368405b
--- /dev/null
+++ b/OpenSim/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs
@@ -0,0 +1,176 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28// SQLite Support
29// A bad idea, but the IRC people told me to!
30
31using System;
32using System.Collections.Generic;
33using System.Data;
34using System.Data.SQLite;
35using libsecondlife;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using OpenSim.Framework.Terrain;
39
40namespace OpenSim.Storage.LocalStorageSQLite
41{
42 public class SQLiteLocalStorage : ILocalStorage
43 {
44 IDbConnection db;
45
46 public SQLiteLocalStorage()
47 {
48 try
49 {
50 string connectionstring = "URI=file:localsim.sdb";
51 db = (IDbConnection)new SQLiteConnection(connectionstring);
52 db.Open();
53 }
54 catch (Exception e)
55 {
56 db.Close();
57 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"SQLiteLocalStorage :Constructor - Exception occured");
58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
59 }
60 }
61
62 public void Initialise(string file)
63 {
64 // Blank
65 }
66
67 public void StorePrim(PrimData prim)
68 {
69 IDbCommand cmd = db.CreateCommand();
70
71 //SECURITY WARNING:
72 // These parameters wont produce SQL injections since they are all integer based, however.
73 // if inserting strings such as name or description, you will need to use appropriate
74 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
75
76 string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) ";
77 sql += "VALUES (";
78 sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW!
79 sql += "\"" + prim.PCode.ToString() + "\",";
80 sql += "\"" + prim.PathBegin.ToString() + "\",";
81 sql += "\"" + prim.PathEnd.ToString() + "\",";
82 sql += "\"" + prim.PathScaleX.ToString() + "\",";
83 sql += "\"" + prim.PathScaleY.ToString() + "\",";
84 sql += "\"" + prim.PathShearX.ToString() + "\",";
85 sql += "\"" + prim.PathShearY.ToString() + "\",";
86 sql += "\"" + prim.PathSkew.ToString() + "\",";
87 sql += "\"" + prim.ProfileBegin.ToString() + "\",";
88 sql += "\"" + prim.ProfileEnd.ToString() + "\",";
89 sql += "\"" + prim.Scale.ToString() + "\",";
90 sql += "\"" + prim.PathCurve.ToString() + "\",";
91 sql += "\"" + prim.ProfileCurve.ToString() + "\",";
92 sql += "\"" + prim.ParentID.ToString() + "\",";
93 sql += "\"" + prim.ProfileHollow.ToString() + "\",";
94 sql += "\"" + prim.PathRadiusOffset.ToString() + "\",";
95 sql += "\"" + prim.PathRevolutions.ToString() + "\",";
96 sql += "\"" + prim.PathTaperX.ToString() + "\",";
97 sql += "\"" + prim.PathTaperY.ToString() + "\",";
98 sql += "\"" + prim.PathTwist.ToString() + "\",";
99 sql += "\"" + prim.PathTwistBegin.ToString() + "\",";
100 sql += "\"" + prim.Texture.ToString() + "\",";
101 sql += "\"" + prim.CreationDate.ToString() + "\",";
102 sql += "\"" + prim.OwnerMask.ToString() + "\",";
103 sql += "\"" + prim.NextOwnerMask.ToString() + "\",";
104 sql += "\"" + prim.GroupMask.ToString() + "\",";
105 sql += "\"" + prim.EveryoneMask.ToString() + "\",";
106 sql += "\"" + prim.BaseMask.ToString() + "\",";
107 sql += "\"" + prim.Position.ToString() + "\",";
108 sql += "\"" + prim.Rotation.ToString() + "\",";
109 sql += "\"" + prim.LocalID.ToString() + "\",";
110 sql += "\"" + prim.FullID.ToString() + "\")";
111
112 cmd.CommandText = sql;
113
114 try
115 {
116 cmd.ExecuteNonQuery();
117 }
118 catch (Exception e)
119 {
120 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"SQLiteLocalStorage :StorePrim - Exception occured");
121 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
122 }
123
124 cmd.Dispose();
125 cmd = null;
126 }
127
128 public void RemovePrim(LLUUID primID)
129 {
130 IDbCommand cmd = db.CreateCommand();
131
132 //SECURITY WARNING:
133 // These parameters wont produce SQL injections since they are all integer based, however.
134 // if inserting strings such as name or description, you will need to use appropriate
135 // measures to prevent SQL injection (although the value of SQL injection in this is limited).
136
137 string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\"";
138
139 cmd.CommandText = sql;
140
141 try
142 {
143 cmd.ExecuteNonQuery();
144 }
145 catch (Exception e)
146 {
147 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"SQLiteLocalStorage :RemovePrim - Exception occured");
148 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
149 }
150
151 cmd.Dispose();
152 cmd = null;
153 }
154
155 public void LoadPrimitives(ILocalStorageReceiver receiver)
156 {
157
158 }
159
160 public float[] LoadWorld()
161 {
162 return new float[65536];
163 }
164
165 public void SaveMap(float[] heightmap)
166 {
167
168 }
169
170 public void ShutDown()
171 {
172 db.Close();
173 db = null;
174 }
175 }
176} \ No newline at end of file
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
new file mode 100644
index 0000000..65a158c
--- /dev/null
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
@@ -0,0 +1,99 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{2270B8FE-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Terrain.BasicTerrain</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Terrain.BasicTerrain</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Drawing" >
66 <HintPath>System.Drawing.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System.Xml" >
74 <HintPath>System.Xml.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="libTerrain-BSD.dll" >
78 <HintPath>..\..\bin\libTerrain-BSD.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 </ItemGroup>
84 <ItemGroup>
85 <Compile Include="TerrainEngine.cs">
86 <SubType>Code</SubType>
87 </Compile>
88 <Compile Include="Properties\AssemblyInfo.cs">
89 <SubType>Code</SubType>
90 </Compile>
91 </ItemGroup>
92 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
93 <PropertyGroup>
94 <PreBuildEvent>
95 </PreBuildEvent>
96 <PostBuildEvent>
97 </PostBuildEvent>
98 </PropertyGroup>
99</Project>
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj.user b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build
new file mode 100644
index 0000000..9c80ac7
--- /dev/null
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build
@@ -0,0 +1,44 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Terrain.BasicTerrain" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Terrain.BasicTerrain" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="TerrainEngine.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="System.Drawing.dll" />
24 <include name="System.Data.dll" />
25 <include name="System.Xml.dll" />
26 <include name="../../bin/libTerrain-BSD.dll" />
27 </references>
28 </csc>
29 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
30 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
31 <copy todir="${project::get-base-directory()}/../../bin/">
32 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
33 <include name="*.dll"/>
34 <include name="*.exe"/>
35 </fileset>
36 </copy>
37 </target>
38 <target name="clean">
39 <delete dir="${bin.dir}" failonerror="false" />
40 <delete dir="${obj.dir}" failonerror="false" />
41 </target>
42 <target name="doc" description="Creates documentation.">
43 </target>
44</project>
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bd74993
--- /dev/null
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Terrain.BasicTerrain")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.Terrain.BasicTerrain")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
new file mode 100644
index 0000000..aa785b0
--- /dev/null
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -0,0 +1,484 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Drawing;
5using libTerrain;
6
7namespace OpenSim.Terrain
8{
9 public class TerrainEngine
10 {
11 /// <summary>
12 /// A [normally] 256x256 heightmap
13 /// </summary>
14 public Channel heightmap;
15
16 /// <summary>
17 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine.
18 /// Counts the number of modifications since the last save. (0 = Untainted)
19 /// </summary>
20 public int tainted;
21
22 int w, h;
23
24 /// <summary>
25 /// Generate a new TerrainEngine instance and creates a new heightmap
26 /// </summary>
27 public TerrainEngine()
28 {
29 w = 256;
30 h = 256;
31 heightmap = new Channel(w, h);
32
33 tainted++;
34 }
35
36 /// <summary>
37 /// Converts the heightmap to a 65536 value 1D floating point array
38 /// </summary>
39 /// <returns>A float[65536] array containing the heightmap</returns>
40 public float[] getHeights1D()
41 {
42 float[] heights = new float[w * h];
43 int i;
44
45 for (i = 0; i < w * h; i++)
46 {
47 heights[i] = (float)heightmap.map[i / w, i % w];
48 }
49
50 return heights;
51 }
52
53 /// <summary>
54 /// Converts the heightmap to a 256x256 value 2D floating point array.
55 /// </summary>
56 /// <returns>An array of 256,256 values containing the heightmap</returns>
57 public float[,] getHeights2D()
58 {
59 float[,] heights = new float[w, h];
60 int x, y;
61 for (x = 0; x < w; x++)
62 {
63 for (y = 0; y < h; y++)
64 {
65 heights[x, y] = (float)heightmap.map[x, y];
66 }
67 }
68 return heights;
69 }
70
71 /// <summary>
72 /// Imports a 1D floating point array into the 2D heightmap array
73 /// </summary>
74 /// <param name="heights">The array to import (must have 65536 members)</param>
75 public void setHeights1D(float[] heights)
76 {
77 int i;
78 for (i = 0; i < w * h; i++)
79 {
80 heightmap.map[i / w, i % w] = heights[i];
81 }
82
83 tainted++;
84 }
85
86 /// <summary>
87 /// Loads a 2D array of values into the heightmap
88 /// </summary>
89 /// <param name="heights">An array of 256,256 float values</param>
90 public void setHeights2D(float[,] heights)
91 {
92 int x, y;
93 for (x = 0; x < w; x++)
94 {
95 for (y = 0; y < h; y++)
96 {
97 heightmap.set(x, y, (double)heights[x, y]);
98 }
99 }
100 tainted++;
101 }
102
103 /// <summary>
104 /// Processes a terrain-specific command
105 /// </summary>
106 /// <param name="args">Commandline arguments (space seperated)</param>
107 /// <param name="resultText">Reference that returns error or help text if returning false</param>
108 /// <returns>If the operation was successful (if not, the error is placed into resultText)</returns>
109 public bool RunTerrainCmd(string[] args, ref string resultText)
110 {
111 string command = args[0];
112
113 try
114 {
115
116 switch (command)
117 {
118 case "help":
119 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
120 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
121 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
122 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n";
123 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
124 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
125 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
126 resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
127 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
128 return false;
129
130 case "seed":
131 setSeed(Convert.ToInt32(args[1]));
132 break;
133
134 case "erode":
135 switch (args[1].ToLower())
136 {
137 case "aerobic":
138 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
139 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]));
140 break;
141 case "thermal":
142 heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4]));
143 break;
144 default:
145 resultText = "Unknown erosion type";
146 return false;
147 }
148 break;
149
150 case "regenerate":
151 hills();
152 break;
153
154 case "rescale":
155 setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2]));
156 break;
157
158 case "multiply":
159 heightmap *= Convert.ToDouble(args[1]);
160 break;
161
162 case "load":
163 switch (args[1].ToLower())
164 {
165 case "f32":
166 loadFromFileF32(args[2]);
167 break;
168
169 case "f64":
170 loadFromFileF64(args[2]);
171 break;
172
173 case "raw":
174 loadFromFileSLRAW(args[2]);
175 break;
176
177 case "img":
178 resultText = "Error - IMG mode is presently unsupported.";
179 return false;
180
181 default:
182 resultText = "Unknown image or data format";
183 return false;
184 }
185 break;
186
187 case "save":
188 switch (args[1].ToLower())
189 {
190 case "f32":
191 writeToFileF32(args[2]);
192 break;
193
194 case "f64":
195 writeToFileF64(args[2]);
196 break;
197
198 case "grdmap":
199 exportImage(args[2], args[3]);
200 break;
201
202 default:
203 resultText = "Unknown image or data format";
204 return false;
205 }
206 break;
207
208 default:
209 resultText = "Unknown terrain command";
210 return false;
211 }
212 return true;
213 }
214 catch (Exception e)
215 {
216 resultText = "Error running terrain command: " + e.ToString();
217 return false;
218 }
219 }
220
221 /// <summary>
222 /// Renormalises the array between min and max
223 /// </summary>
224 /// <param name="min">Minimum value of the new array</param>
225 /// <param name="max">Maximum value of the new array</param>
226 public void setRange(float min, float max)
227 {
228 heightmap.normalise((double)min, (double)max);
229 tainted++;
230 }
231
232 /// <summary>
233 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
234 /// </summary>
235 /// <remarks>TODO: Move this to libTerrain itself</remarks>
236 /// <param name="filename">The filename of the double array to import</param>
237 public void loadFromFileF64(string filename)
238 {
239 System.IO.FileInfo file = new System.IO.FileInfo(filename);
240 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
241 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
242 int x, y;
243 for (x = 0; x < w; x++)
244 {
245 for (y = 0; y < h; y++)
246 {
247 heightmap.map[x, y] = bs.ReadDouble();
248 }
249 }
250
251 bs.Close();
252 s.Close();
253
254 tainted++;
255 }
256
257 /// <summary>
258 /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
259 /// </summary>
260 /// <remarks>TODO: Move this to libTerrain itself</remarks>
261 /// <param name="filename">The filename of the float array to import</param>
262 public void loadFromFileF32(string filename)
263 {
264 System.IO.FileInfo file = new System.IO.FileInfo(filename);
265 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
266 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
267 int x, y;
268 for (x = 0; x < w; x++)
269 {
270 for (y = 0; y < h; y++)
271 {
272 heightmap.map[x, y] = (double)bs.ReadSingle();
273 }
274 }
275
276 bs.Close();
277 s.Close();
278
279 tainted++;
280 }
281
282 /// <summary>
283 /// Loads a file formatted in the SL .RAW Format used on the main grid
284 /// </summary>
285 /// <remarks>This file format stinks and is best avoided.</remarks>
286 /// <param name="filename">A path to the .RAW format</param>
287 public void loadFromFileSLRAW(string filename)
288 {
289 System.IO.FileInfo file = new System.IO.FileInfo(filename);
290 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
291 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
292 int x, y;
293 for (x = 0; x < w; x++)
294 {
295 for (y = 0; y < h; y++)
296 {
297 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
298 bs.ReadBytes(11); // Advance the stream to next bytes.
299 }
300 }
301
302 bs.Close();
303 s.Close();
304
305 tainted++;
306 }
307
308 /// <summary>
309 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
310 /// </summary>
311 /// <param name="filename">The desired output filename</param>
312 public void writeToFileF64(string filename)
313 {
314 System.IO.FileInfo file = new System.IO.FileInfo(filename);
315 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
316 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
317
318 int x, y;
319 for (x = 0; x < w; x++)
320 {
321 for (y = 0; y < h; y++)
322 {
323 bs.Write(heightmap.get(x, y));
324 }
325 }
326
327 bs.Close();
328 s.Close();
329 }
330
331 /// <summary>
332 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array
333 /// </summary>
334 /// <param name="filename">The desired output filename</param>
335 public void writeToFileF32(string filename)
336 {
337 System.IO.FileInfo file = new System.IO.FileInfo(filename);
338 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
339 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
340
341 int x, y;
342 for (x = 0; x < w; x++)
343 {
344 for (y = 0; y < h; y++)
345 {
346 bs.Write((float)heightmap.get(x, y));
347 }
348 }
349
350 bs.Close();
351 s.Close();
352 }
353
354 /// <summary>
355 /// Sets the random seed to be used by procedural functions which involve random numbers.
356 /// </summary>
357 /// <param name="val">The desired seed</param>
358 public void setSeed(int val)
359 {
360 heightmap.seed = val;
361 }
362
363 /// <summary>
364 /// Raises land in a sphere around the specified coordinates
365 /// </summary>
366 /// <param name="rx">Center of the sphere on the X axis</param>
367 /// <param name="ry">Center of the sphere on the Y axis</param>
368 /// <param name="size">The radius of the sphere</param>
369 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
370 public void raise(double rx, double ry, double size, double amount)
371 {
372 lock (heightmap)
373 {
374 heightmap.raise(rx, ry, size, amount);
375 }
376
377 tainted++;
378 }
379
380 /// <summary>
381 /// Lowers the land in a sphere around the specified coordinates
382 /// </summary>
383 /// <param name="rx">The center of the sphere at the X axis</param>
384 /// <param name="ry">The center of the sphere at the Y axis</param>
385 /// <param name="size">The radius of the sphere in meters</param>
386 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
387 public void lower(double rx, double ry, double size, double amount)
388 {
389 lock (heightmap)
390 {
391 heightmap.lower(rx, ry, size, amount);
392 }
393
394 tainted++;
395 }
396
397 /// <summary>
398 /// Generates a simple set of hills in the shape of an island
399 /// </summary>
400 public void hills()
401 {
402 lock (heightmap)
403 {
404 heightmap.hillsSpheres(200, 20, 40, true, true, false);
405 heightmap.normalise();
406 heightmap *= 60.0; // Raise to 60m
407 }
408
409 tainted++;
410 }
411
412 /// <summary>
413 /// Multiplies the heightfield by val
414 /// </summary>
415 /// <param name="meep">The heightfield</param>
416 /// <param name="val">The multiplier</param>
417 /// <returns></returns>
418 public static TerrainEngine operator *(TerrainEngine meep, Double val)
419 {
420 meep.heightmap *= val;
421 meep.tainted++;
422 return meep;
423 }
424
425 /// <summary>
426 /// Returns the height at the coordinates x,y
427 /// </summary>
428 /// <param name="x">X Coordinate</param>
429 /// <param name="y">Y Coordinate</param>
430 /// <returns></returns>
431 public float this[int x, int y]
432 {
433 get
434 {
435 return (float)heightmap.get(x, y);
436 }
437 set
438 {
439 tainted++;
440 heightmap.set(x, y, (double)value);
441 }
442 }
443
444 /// <summary>
445 /// Exports the current heightmap to a PNG file
446 /// </summary>
447 /// <param name="filename">The destination filename for the image</param>
448 /// <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>
449 public void exportImage(string filename, string gradientmap)
450 {
451 try
452 {
453 Bitmap gradientmapLd = new Bitmap(gradientmap);
454
455 int pallete = gradientmapLd.Height;
456
457 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
458 Color[] colours = new Color[pallete];
459
460 for (int i = 0; i < pallete; i++)
461 {
462 colours[i] = gradientmapLd.GetPixel(0, i);
463 }
464
465 Channel copy = heightmap.copy();
466 for (int x = 0; x < copy.w; x++)
467 {
468 for (int y = 0; y < copy.h; y++)
469 {
470 // 512 is the largest possible height before colours clamp
471 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete);
472 bmp.SetPixel(x, y, colours[colorindex]);
473 }
474 }
475
476 bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
477 }
478 catch (Exception e)
479 {
480 Console.WriteLine("Failed generating terrain map: " + e.ToString());
481 }
482 }
483 }
484} \ No newline at end of file
diff --git a/OpenSim/OpenSim/Application.cs b/OpenSim/OpenSim/Application.cs
new file mode 100644
index 0000000..3f9c0ec
--- /dev/null
+++ b/OpenSim/OpenSim/Application.cs
@@ -0,0 +1,95 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.UserServer;
5using OpenSim.Framework.Console;
6
7namespace OpenSim
8{
9 public class Application
10 {
11 //could move our main function into OpenSimMain and kill this class
12 [STAThread]
13 public static void Main(string[] args)
14 {
15 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
16 Console.WriteLine("Starting...\n");
17
18 bool sandBoxMode = false;
19 bool startLoginServer = false;
20 string physicsEngine = "basicphysics";
21 bool allowFlying = false;
22 bool userAccounts = false;
23 bool gridLocalAsset = false;
24 bool useConfigFile = false;
25 bool silent = false;
26 string configFile = "simconfig.xml";
27
28 for (int i = 0; i < args.Length; i++)
29 {
30 if (args[i] == "-sandbox")
31 {
32 sandBoxMode = true;
33 startLoginServer = true;
34 }
35 /*
36 if (args[i] == "-loginserver")
37 {
38 startLoginServer = true;
39 }*/
40 if (args[i] == "-accounts")
41 {
42 userAccounts = true;
43 }
44 if (args[i] == "-realphysx")
45 {
46 physicsEngine = "RealPhysX";
47 allowFlying = true;
48 }
49 if (args[i] == "-ode")
50 {
51 physicsEngine = "OpenDynamicsEngine";
52 allowFlying = true;
53 }
54 if (args[i] == "-localasset")
55 {
56 gridLocalAsset = true;
57 }
58 if (args[i] == "-configfile")
59 {
60 useConfigFile = true;
61 }
62 if (args[i] == "-noverbose")
63 {
64 silent = true;
65 }
66 if (args[i] == "-config")
67 {
68 try
69 {
70 i++;
71 configFile = args[i];
72 }
73 catch (Exception e)
74 {
75 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
76 }
77 }
78 }
79
80 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
81 // OpenSimRoot.Instance.Application = sim;
82 sim.m_sandbox = sandBoxMode;
83 sim.user_accounts = userAccounts;
84 sim.gridLocalAsset = gridLocalAsset;
85 OpenSim.world.Avatar.PhysicsEngineFlying = allowFlying;
86
87 sim.StartUp();
88
89 while (true)
90 {
91 OpenSim.Framework.Console.MainConsole.Instance.MainConsolePrompt();
92 }
93 }
94 }
95}
diff --git a/OpenSim/OpenSim/OpenSim.csproj b/OpenSim/OpenSim/OpenSim.csproj
new file mode 100644
index 0000000..069c5c6
--- /dev/null
+++ b/OpenSim/OpenSim/OpenSim.csproj
@@ -0,0 +1,147 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{438A9556-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Axiom.MathLib.dll" >
74 <HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Db4objects.Db4o.dll" >
78 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
84 <Name>OpenSim.Terrain.BasicTerrain</Name>
85 <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
90 <Name>OpenSim.Framework</Name>
91 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 <ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
96 <Name>OpenSim.Framework.Console</Name>
97 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private>
100 </ProjectReference>
101 <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
102 <Name>OpenSim.Physics.Manager</Name>
103 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private>
106 </ProjectReference>
107 <ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj">
108 <Name>OpenSim.Servers</Name>
109 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 <ProjectReference Include="..\OpenSim.RegionServer\OpenSim.RegionServer.csproj">
114 <Name>OpenSim.RegionServer</Name>
115 <Project>{632E1BFD-0000-0000-0000-000000000000}</Project>
116 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
117 <Private>False</Private>
118 </ProjectReference>
119 <ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
120 <Name>OpenSim.GenericConfig.Xml</Name>
121 <Project>{E88EF749-0000-0000-0000-000000000000}</Project>
122 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
123 <Private>False</Private>
124 </ProjectReference>
125 <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj">
126 <Name>XMLRPC</Name>
127 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
128 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
129 <Private>False</Private>
130 </ProjectReference>
131 </ItemGroup>
132 <ItemGroup>
133 <Compile Include="Application.cs">
134 <SubType>Code</SubType>
135 </Compile>
136 <Compile Include="OpenSimMain.cs">
137 <SubType>Code</SubType>
138 </Compile>
139 </ItemGroup>
140 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
141 <PropertyGroup>
142 <PreBuildEvent>
143 </PreBuildEvent>
144 <PostBuildEvent>
145 </PostBuildEvent>
146 </PropertyGroup>
147</Project>
diff --git a/OpenSim/OpenSim/OpenSim.csproj.user b/OpenSim/OpenSim/OpenSim.csproj.user
new file mode 100644
index 0000000..1422ebf
--- /dev/null
+++ b/OpenSim/OpenSim/OpenSim.csproj.user
@@ -0,0 +1,13 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <StartArguments>-loginserver -sandbox -accounts</StartArguments>
6 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
7 <LastOpenVersion>8.0.50727</LastOpenVersion>
8 <ProjectView>ProjectFiles</ProjectView>
9 <ProjectTrust>0</ProjectTrust>
10 </PropertyGroup>
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
12 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
13</Project>
diff --git a/OpenSim/OpenSim/OpenSim.exe.build b/OpenSim/OpenSim/OpenSim.exe.build
new file mode 100644
index 0000000..4f8ca8a
--- /dev/null
+++ b/OpenSim/OpenSim/OpenSim.exe.build
@@ -0,0 +1,52 @@
1<?xml version="1.0" ?>
2<project name="OpenSim" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="OpenSim" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Application.cs" />
15 <include name="OpenSimMain.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="System.Xml.dll" />
24 <include name="../../bin/libsecondlife.dll" />
25 <include name="../../bin/Axiom.MathLib.dll" />
26 <include name="../../bin/Db4objects.Db4o.dll" />
27 <include name="../../bin/OpenSim.Terrain.BasicTerrain.dll" />
28 <include name="../../bin/OpenSim.Framework.dll" />
29 <include name="../../bin/OpenSim.Framework.Console.dll" />
30 <include name="../../bin/OpenSim.Physics.Manager.dll" />
31 <include name="../../bin/OpenSim.Servers.dll" />
32 <include name="../../bin/OpenSim.RegionServer.dll" />
33 <include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
34 <include name="../../bin/XMLRPC.dll" />
35 </references>
36 </csc>
37 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
38 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
39 <copy todir="${project::get-base-directory()}/../../bin/">
40 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
41 <include name="*.dll"/>
42 <include name="*.exe"/>
43 </fileset>
44 </copy>
45 </target>
46 <target name="clean">
47 <delete dir="${bin.dir}" failonerror="false" />
48 <delete dir="${obj.dir}" failonerror="false" />
49 </target>
50 <target name="doc" description="Creates documentation.">
51 </target>
52</project>
diff --git a/OpenSim/OpenSim/OpenSimMain.cs b/OpenSim/OpenSim/OpenSimMain.cs
new file mode 100644
index 0000000..9025316
--- /dev/null
+++ b/OpenSim/OpenSim/OpenSimMain.cs
@@ -0,0 +1,533 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* All rights reserved.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the <organization> nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29using System;
30using System.Text;
31using System.IO;
32using System.Threading;
33using System.Net;
34using System.Net.Sockets;
35using System.Timers;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using libsecondlife.Packets;
41using OpenSim.world;
42using OpenSim.Terrain;
43using OpenSim.Framework.Interfaces;
44using OpenSim.Framework.Types;
45using OpenSim.UserServer;
46using OpenSim.Assets;
47using OpenSim.CAPS;
48using OpenSim.Framework.Console;
49using OpenSim.Physics.Manager;
50using Nwc.XmlRpc;
51using OpenSim.Servers;
52using OpenSim.GenericConfig;
53
54namespace OpenSim
55{
56
57 public class OpenSimMain : RegionServerBase, conscmd_callback
58 {
59 private CheckSumServer checkServer;
60
61 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
62 {
63 this.configFileSetup = useConfigFile;
64 m_sandbox = sandBoxMode;
65 m_loginserver = startLoginServer;
66 m_physicsEngine = physicsEngine;
67 m_config = configFile;
68
69 m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent);
70 OpenSim.Framework.Console.MainConsole.Instance = m_console;
71 }
72
73 /// <summary>
74 /// Performs initialisation of the world, such as loading configuration from disk.
75 /// </summary>
76 public override void StartUp()
77 {
78 this.regionData = new RegionInfo();
79 try
80 {
81 this.localConfig = new XmlConfig(m_config);
82 this.localConfig.LoadData();
83 }
84 catch (Exception e)
85 {
86 Console.WriteLine(e.Message);
87 }
88 if (this.configFileSetup)
89 {
90 this.SetupFromConfigFile(this.localConfig);
91 }
92 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
93 this.regionData.InitConfig(this.m_sandbox, this.localConfig);
94 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
95
96 GridServers = new Grid();
97 if (m_sandbox)
98 {
99 this.SetupLocalGridServers();
100 //Authenticate Session Handler
101 AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal();
102 this.AuthenticateSessionsHandler = authen;
103 this.checkServer = new CheckSumServer(12036);
104 this.checkServer.ServerListener();
105 }
106 else
107 {
108 this.SetupRemoteGridServers();
109 //Authenticate Session Handler
110 AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote();
111 this.AuthenticateSessionsHandler = authen;
112 }
113
114 startuptime = DateTime.Now;
115
116 try
117 {
118 AssetCache = new AssetCache(GridServers.AssetServer);
119 InventoryCache = new InventoryCache();
120 }
121 catch (Exception e)
122 {
123 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache");
124 Environment.Exit(1);
125 }
126
127 m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler);
128
129 //should be passing a IGenericConfig object to these so they can read the config data they want from it
130 GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
131 IGridServer gridServer = GridServers.GridServer;
132 gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
133
134 if (!m_sandbox)
135 {
136 this.ConnectToRemoteGridServer();
137 }
138
139 this.SetupLocalWorld();
140
141 if (m_sandbox)
142 {
143 AssetCache.LoadDefaultTextureSet();
144 }
145
146 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
147
148 this.SetupHttpListener();
149
150 //Login server setup
151 LoginServer loginServer = null;
152 LoginServer adminLoginServer = null;
153
154 bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
155 if (sandBoxWithLoginServer)
156 {
157 loginServer = new LoginServer(regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
158 loginServer.Startup();
159 loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler).AddNewSession);
160
161 if (user_accounts)
162 {
163 //sandbox mode with loginserver using accounts
164 this.GridServers.UserServer = loginServer;
165 adminLoginServer = loginServer;
166
167 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
168 }
169 else
170 {
171 //sandbox mode with loginserver not using accounts
172 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
173 }
174 }
175
176 //Web front end setup
177 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
178 adminWebFront.LoadMethods(httpServer);
179
180 //Start http server
181 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
182 httpServer.Start();
183
184 // Start UDP server
185 this.m_udpServer.ServerListener();
186
187 m_heartbeatTimer.Enabled = true;
188 m_heartbeatTimer.Interval = 100;
189 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
190 }
191
192 # region Setup methods
193 protected override void SetupLocalGridServers()
194 {
195 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
196 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
197
198 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
199
200 try
201 {
202 GridServers.Initialise();
203 }
204 catch (Exception e)
205 {
206 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
207 Environment.Exit(1);
208 }
209 }
210
211 protected override void SetupRemoteGridServers()
212 {
213 if (this.gridLocalAsset)
214 {
215 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
216 }
217 else
218 {
219 GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
220 }
221 GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
222
223 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
224
225 try
226 {
227 GridServers.Initialise();
228 }
229 catch (Exception e)
230 {
231 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
232 Environment.Exit(1);
233 }
234 }
235
236 protected override void SetupLocalWorld()
237 {
238 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
239 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
240 m_console.componentname = "Region " + regionData.RegionName;
241
242 m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
243 LocalWorld.InventoryCache = InventoryCache;
244 LocalWorld.AssetCache = AssetCache;
245
246 this.m_udpServer.LocalWorld = LocalWorld;
247 this.m_udpServer.PacketServer.RegisterClientPacketHandlers();
248
249 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
250 this.physManager.LoadPlugins();
251
252 LocalWorld.m_datastore = this.regionData.DataStore;
253
254 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
255 LocalWorld.LoadWorldMap();
256
257 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
258 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
259 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
260 LocalWorld.LoadPrimsFromStorage();
261 }
262
263 protected override void SetupHttpListener()
264 {
265 httpServer = new BaseHttpServer(regionData.IPListenPort);
266
267 if (this.GridServers.GridServer.GetName() == "Remote")
268 {
269
270 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
271 httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser);
272
273 httpServer.AddXmlRPCHandler("agent_crossing",
274 delegate(XmlRpcRequest request)
275 {
276 Hashtable requestData = (Hashtable)request.Params[0];
277 uint circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
278
279 AgentCircuitData agent_data = new AgentCircuitData();
280 agent_data.firstname = (string)requestData["firstname"];
281 agent_data.lastname = (string)requestData["lastname"];
282 agent_data.circuitcode = circuitcode;
283 agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
284
285 AuthenticateSessionsHandler.UpdateAgentData(agent_data);
286
287 return new XmlRpcResponse();
288 });
289
290 httpServer.AddRestHandler("GET", "/simstatus/",
291 delegate(string request, string path, string param)
292 {
293 return "OK";
294 });
295 }
296 }
297
298 protected override void ConnectToRemoteGridServer()
299 {
300 if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
301 {
302 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!");
303 }
304 else
305 {
306 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
307 Shutdown();
308 }
309
310 GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
311
312 // If we are being told to load a file, load it.
313 string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
314
315 if (!String.IsNullOrEmpty(dataUri))
316 {
317 this.LocalWorld.m_datastore = dataUri;
318 }
319
320 if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
321 {
322 // The grid server has told us who we are
323 // We must obey the grid server.
324 try
325 {
326 regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
327 regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
328 regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
329 }
330 catch (Exception e)
331 {
332 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
333 Environment.Exit(1);
334 }
335 }
336 }
337
338 #endregion
339
340 private void SetupFromConfigFile(IGenericConfig configData)
341 {
342 try
343 {
344 // SandBoxMode
345 string attri = "";
346 attri = configData.GetAttribute("SandBox");
347 if ((attri == "") || ((attri != "false") && (attri != "true")))
348 {
349 this.m_sandbox = false;
350 configData.SetAttribute("SandBox", "false");
351 }
352 else
353 {
354 this.m_sandbox = Convert.ToBoolean(attri);
355 }
356
357 // LoginServer
358 attri = "";
359 attri = configData.GetAttribute("LoginServer");
360 if ((attri == "") || ((attri != "false") && (attri != "true")))
361 {
362 this.m_loginserver = false;
363 configData.SetAttribute("LoginServer", "false");
364 }
365 else
366 {
367 this.m_loginserver = Convert.ToBoolean(attri);
368 }
369
370 // Sandbox User accounts
371 attri = "";
372 attri = configData.GetAttribute("UserAccount");
373 if ((attri == "") || ((attri != "false") && (attri != "true")))
374 {
375 this.user_accounts = false;
376 configData.SetAttribute("UserAccounts", "false");
377 }
378 else if (attri == "true")
379 {
380 this.user_accounts = Convert.ToBoolean(attri);
381 }
382
383 // Grid mode hack to use local asset server
384 attri = "";
385 attri = configData.GetAttribute("LocalAssets");
386 if ((attri == "") || ((attri != "false") && (attri != "true")))
387 {
388 this.gridLocalAsset = false;
389 configData.SetAttribute("LocalAssets", "false");
390 }
391 else if (attri == "true")
392 {
393 this.gridLocalAsset = Convert.ToBoolean(attri);
394 }
395
396
397 attri = "";
398 attri = configData.GetAttribute("PhysicsEngine");
399 switch (attri)
400 {
401 default:
402 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
403 Environment.Exit(1);
404 break;
405
406 case "":
407 this.m_physicsEngine = "basicphysics";
408 configData.SetAttribute("PhysicsEngine", "basicphysics");
409 OpenSim.world.Avatar.PhysicsEngineFlying = false;
410 break;
411
412 case "basicphysics":
413 this.m_physicsEngine = "basicphysics";
414 configData.SetAttribute("PhysicsEngine", "basicphysics");
415 OpenSim.world.Avatar.PhysicsEngineFlying = false;
416 break;
417
418 case "RealPhysX":
419 this.m_physicsEngine = "RealPhysX";
420 OpenSim.world.Avatar.PhysicsEngineFlying = true;
421 break;
422
423 case "OpenDynamicsEngine":
424 this.m_physicsEngine = "OpenDynamicsEngine";
425 OpenSim.world.Avatar.PhysicsEngineFlying = true;
426 break;
427 }
428
429 configData.Commit();
430 }
431 catch (Exception e)
432 {
433 Console.WriteLine(e.Message);
434 Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data");
435 Console.WriteLine("Can not continue starting up");
436 Environment.Exit(1);
437 }
438 }
439
440 /// <summary>
441 /// Performs any last-minute sanity checking and shuts down the region server
442 /// </summary>
443 public virtual void Shutdown()
444 {
445 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads");
446 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread");
447 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients");
448 // IMPLEMENT THIS
449 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating");
450 LocalWorld.Close();
451 GridServers.Close();
452 m_console.Close();
453 Environment.Exit(0);
454 }
455
456 /// <summary>
457 /// Performs per-frame updates regularly
458 /// </summary>
459 /// <param name="sender"></param>
460 /// <param name="e"></param>
461 void Heartbeat(object sender, System.EventArgs e)
462 {
463 LocalWorld.Update();
464 }
465
466 #region Console Commands
467 /// <summary>
468 /// Runs commands issued by the server console from the operator
469 /// </summary>
470 /// <param name="command">The first argument of the parameter (the command)</param>
471 /// <param name="cmdparams">Additional arguments passed to the command</param>
472 public void RunCmd(string command, string[] cmdparams)
473 {
474 switch (command)
475 {
476 case "help":
477 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users");
478 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown");
479 break;
480
481 case "show":
482 Show(cmdparams[0]);
483 break;
484
485 case "terrain":
486 string result = "";
487 if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result))
488 {
489 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result);
490 }
491 break;
492
493 case "shutdown":
494 Shutdown();
495 break;
496
497 default:
498 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command");
499 break;
500 }
501 }
502
503 /// <summary>
504 /// Outputs to the console information about the region
505 /// </summary>
506 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
507 public void Show(string ShowWhat)
508 {
509 switch (ShowWhat)
510 {
511 case "uptime":
512 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString());
513 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString());
514 break;
515 case "users":
516 OpenSim.world.Avatar TempAv;
517 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
518 foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
519 {
520 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
521 {
522 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
523 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
524 }
525 }
526 break;
527 }
528 }
529 #endregion
530 }
531
532
533} \ No newline at end of file