diff options
Diffstat (limited to '')
57 files changed, 5188 insertions, 0 deletions
diff --git a/ConvertToPlugins/src/Assets/AssetCache.cs b/ConvertToPlugins/src/Assets/AssetCache.cs new file mode 100644 index 0000000..d35b482 --- /dev/null +++ b/ConvertToPlugins/src/Assets/AssetCache.cs | |||
@@ -0,0 +1,436 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Threading; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim; | ||
34 | using OpenSim.GridServers; | ||
35 | |||
36 | namespace OpenSim.Assets | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Manages local cache of assets and their sending to viewers. | ||
40 | /// </summary> | ||
41 | public class AssetCache : IAssetReceiver | ||
42 | { | ||
43 | public Dictionary<libsecondlife.LLUUID, AssetInfo> Assets; | ||
44 | public Dictionary<libsecondlife.LLUUID, TextureImage> Textures; | ||
45 | |||
46 | public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers | ||
47 | public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent | ||
48 | |||
49 | public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server | ||
50 | public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server | ||
51 | |||
52 | private IAssetServer _assetServer; | ||
53 | private Thread _assetCacheThread; | ||
54 | |||
55 | /// <summary> | ||
56 | /// | ||
57 | /// </summary> | ||
58 | public AssetCache( IAssetServer assetServer) | ||
59 | { | ||
60 | _assetServer = assetServer; | ||
61 | _assetServer.SetReceiver(this); | ||
62 | Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo> (); | ||
63 | Textures = new Dictionary<libsecondlife.LLUUID, TextureImage> (); | ||
64 | this._assetCacheThread = new Thread( new ThreadStart(RunAssetManager)); | ||
65 | this._assetCacheThread.IsBackground = true; | ||
66 | this._assetCacheThread.Start(); | ||
67 | } | ||
68 | |||
69 | /// <summary> | ||
70 | /// | ||
71 | /// </summary> | ||
72 | private void RunAssetManager() | ||
73 | { | ||
74 | this.ProcessAssetQueue(); | ||
75 | this.ProcessTextureQueue(); | ||
76 | Thread.Sleep(100); | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// | ||
81 | /// </summary> | ||
82 | private void ProcessTextureQueue() | ||
83 | { | ||
84 | if(this.TextureRequests.Count == 0) | ||
85 | { | ||
86 | //no requests waiting | ||
87 | return; | ||
88 | } | ||
89 | int num; | ||
90 | |||
91 | if(this.TextureRequests.Count < 5) | ||
92 | { | ||
93 | //lower than 5 so do all of them | ||
94 | num = this.TextureRequests.Count; | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | num=5; | ||
99 | } | ||
100 | AssetRequest req; | ||
101 | for(int i = 0; i < num; i++) | ||
102 | { | ||
103 | req=(AssetRequest)this.TextureRequests[i]; | ||
104 | |||
105 | if(req.PacketCounter == 0) | ||
106 | { | ||
107 | //first time for this request so send imagedata packet | ||
108 | if(req.NumPackets == 1) | ||
109 | { | ||
110 | //only one packet so send whole file | ||
111 | ImageDataPacket im = new ImageDataPacket(); | ||
112 | im.ImageID.Packets = 1; | ||
113 | im.ImageID.ID = req.ImageInfo.FullID; | ||
114 | im.ImageID.Size = (uint)req.ImageInfo.Data.Length; | ||
115 | im.ImageData.Data = req.ImageInfo.Data; | ||
116 | im.ImageID.Codec = 2; | ||
117 | req.RequestUser.OutPacket(im); | ||
118 | req.PacketCounter++; | ||
119 | //req.ImageInfo.l= time; | ||
120 | //System.Console.WriteLine("sent texture: "+req.image_info.FullID); | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | //more than one packet so split file up | ||
125 | ImageDataPacket im = new ImageDataPacket(); | ||
126 | im.ImageID.Packets = (ushort)req.NumPackets; | ||
127 | im.ImageID.ID = req.ImageInfo.FullID; | ||
128 | im.ImageID.Size = (uint)req.ImageInfo.Data.Length; | ||
129 | im.ImageData.Data = new byte[600]; | ||
130 | Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); | ||
131 | im.ImageID.Codec = 2; | ||
132 | req.RequestUser.OutPacket(im); | ||
133 | req.PacketCounter++; | ||
134 | //req.ImageInfo.last_used = time; | ||
135 | //System.Console.WriteLine("sent first packet of texture: | ||
136 | } | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | //send imagepacket | ||
141 | //more than one packet so split file up | ||
142 | ImagePacketPacket im = new ImagePacketPacket(); | ||
143 | im.ImageID.Packet = (ushort)req.PacketCounter; | ||
144 | im.ImageID.ID = req.ImageInfo.FullID; | ||
145 | int size = req.ImageInfo.Data.Length - 600 - 1000*(req.PacketCounter - 1); | ||
146 | if(size > 1000) size = 1000; | ||
147 | im.ImageData.Data = new byte[size]; | ||
148 | Array.Copy(req.ImageInfo.Data, 600 + 1000*(req.PacketCounter - 1), im.ImageData.Data, 0, size); | ||
149 | req.RequestUser.OutPacket(im); | ||
150 | req.PacketCounter++; | ||
151 | //req.ImageInfo.last_used = time; | ||
152 | //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | //remove requests that have been completed | ||
157 | int count = 0; | ||
158 | for(int i = 0; i < num; i++) | ||
159 | { | ||
160 | req=(AssetRequest)this.TextureRequests[count]; | ||
161 | if(req.PacketCounter == req.NumPackets) | ||
162 | { | ||
163 | this.TextureRequests.Remove(req); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | count++; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | } | ||
172 | public void AssetReceived(AssetBase asset, bool IsTexture) | ||
173 | { | ||
174 | //check if it is a texture or not | ||
175 | //then add to the correct cache list | ||
176 | //then check for waiting requests for this asset/texture (in the Requested lists) | ||
177 | //and move those requests into the Requests list. | ||
178 | if(IsTexture) | ||
179 | { | ||
180 | TextureImage image = new TextureImage(asset); | ||
181 | this.Textures.Add(image.FullID, image); | ||
182 | if(this.RequestedTextures.ContainsKey(image.FullID)) | ||
183 | { | ||
184 | AssetRequest req = this.RequestedTextures[image.FullID]; | ||
185 | req.ImageInfo = image; | ||
186 | this.RequestedTextures.Remove(image.FullID); | ||
187 | this.TextureRequests.Add(req); | ||
188 | } | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | AssetInfo assetInf = new AssetInfo(asset); | ||
193 | this.Assets.Add(assetInf.FullID, assetInf); | ||
194 | if(this.RequestedAssets.ContainsKey(assetInf.FullID)) | ||
195 | { | ||
196 | AssetRequest req = this.RequestedAssets[assetInf.FullID]; | ||
197 | req.AssetInf = assetInf; | ||
198 | this.RequestedAssets.Remove(assetInf.FullID); | ||
199 | this.AssetRequests.Add(req); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | |||
204 | public void AssetNotFound(AssetBase asset) | ||
205 | { | ||
206 | //the asset server had no knowledge of requested asset | ||
207 | |||
208 | } | ||
209 | |||
210 | #region Assets | ||
211 | /// <summary> | ||
212 | /// | ||
213 | /// </summary> | ||
214 | /// <param name="userInfo"></param> | ||
215 | /// <param name="transferRequest"></param> | ||
216 | public void AddAssetRequest(OpenSimClient userInfo, TransferRequestPacket transferRequest) | ||
217 | { | ||
218 | LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); | ||
219 | //check to see if asset is in local cache, if not we need to request it from asset server. | ||
220 | if(!this.Assets.ContainsKey(requestID)) | ||
221 | { | ||
222 | //not found asset | ||
223 | // so request from asset server | ||
224 | AssetRequest request = new AssetRequest(); | ||
225 | request.RequestUser = userInfo; | ||
226 | request.RequestAssetID = requestID; | ||
227 | request.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
228 | this.RequestedAssets.Add(requestID,request); | ||
229 | this._assetServer.RequestAsset(requestID, false); | ||
230 | return; | ||
231 | } | ||
232 | //it is in our cache | ||
233 | AssetInfo asset = this.Assets[requestID]; | ||
234 | |||
235 | //work out how many packets it should be sent in | ||
236 | // and add to the AssetRequests list | ||
237 | AssetRequest req = new AssetRequest(); | ||
238 | req.RequestUser = userInfo; | ||
239 | req.RequestAssetID = requestID; | ||
240 | req.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
241 | req.AssetInf = asset; | ||
242 | |||
243 | if(asset.Data.LongLength>600) | ||
244 | { | ||
245 | //over 600 bytes so split up file | ||
246 | req.NumPackets = 1 + (int)(asset.Data.Length-600+999)/1000; | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | req.NumPackets = 1; | ||
251 | } | ||
252 | |||
253 | this.AssetRequests.Add(req); | ||
254 | } | ||
255 | |||
256 | /// <summary> | ||
257 | /// | ||
258 | /// </summary> | ||
259 | private void ProcessAssetQueue() | ||
260 | { | ||
261 | if(this.AssetRequests.Count == 0) | ||
262 | { | ||
263 | //no requests waiting | ||
264 | return; | ||
265 | } | ||
266 | int num; | ||
267 | |||
268 | if(this.AssetRequests.Count < 5) | ||
269 | { | ||
270 | //lower than 5 so do all of them | ||
271 | num = this.AssetRequests.Count; | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | num=5; | ||
276 | } | ||
277 | AssetRequest req; | ||
278 | for(int i = 0; i < num; i++) | ||
279 | { | ||
280 | req=(AssetRequest)this.AssetRequests[i]; | ||
281 | |||
282 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
283 | Transfer.TransferInfo.ChannelType = 2; | ||
284 | Transfer.TransferInfo.Status = 0; | ||
285 | Transfer.TransferInfo.TargetType = 0; | ||
286 | Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); | ||
287 | Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; | ||
288 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | ||
289 | req.RequestUser.OutPacket(Transfer); | ||
290 | |||
291 | if(req.NumPackets == 1) | ||
292 | { | ||
293 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
294 | TransferPacket.TransferData.Packet = 0; | ||
295 | TransferPacket.TransferData.ChannelType = 2; | ||
296 | TransferPacket.TransferData.TransferID=req.TransferRequestID; | ||
297 | TransferPacket.TransferData.Data = req.AssetInf.Data; | ||
298 | TransferPacket.TransferData.Status = 1; | ||
299 | req.RequestUser.OutPacket(TransferPacket); | ||
300 | } | ||
301 | else | ||
302 | { | ||
303 | //more than one packet so split file up , for now it can't be bigger than 2000 bytes | ||
304 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
305 | TransferPacket.TransferData.Packet = 0; | ||
306 | TransferPacket.TransferData.ChannelType = 2; | ||
307 | TransferPacket.TransferData.TransferID=req.TransferRequestID; | ||
308 | byte[] chunk = new byte[1000]; | ||
309 | Array.Copy(req.AssetInf.Data,chunk,1000); | ||
310 | TransferPacket.TransferData.Data = chunk; | ||
311 | TransferPacket.TransferData.Status = 0; | ||
312 | req.RequestUser.OutPacket(TransferPacket); | ||
313 | |||
314 | TransferPacket = new TransferPacketPacket(); | ||
315 | TransferPacket.TransferData.Packet = 1; | ||
316 | TransferPacket.TransferData.ChannelType = 2; | ||
317 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
318 | byte[] chunk1 = new byte[(req.AssetInf.Data.Length-1000)]; | ||
319 | Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); | ||
320 | TransferPacket.TransferData.Data = chunk1; | ||
321 | TransferPacket.TransferData.Status = 1; | ||
322 | req.RequestUser.OutPacket(TransferPacket); | ||
323 | } | ||
324 | |||
325 | } | ||
326 | |||
327 | //remove requests that have been completed | ||
328 | for(int i = 0; i < num; i++) | ||
329 | { | ||
330 | this.AssetRequests.RemoveAt(0); | ||
331 | } | ||
332 | |||
333 | } | ||
334 | |||
335 | #endregion | ||
336 | |||
337 | #region Textures | ||
338 | /// <summary> | ||
339 | /// | ||
340 | /// </summary> | ||
341 | /// <param name="userInfo"></param> | ||
342 | /// <param name="imageID"></param> | ||
343 | public void AddTextureRequest(OpenSimClient userInfo, LLUUID imageID) | ||
344 | { | ||
345 | //check to see if texture is in local cache, if not request from asset server | ||
346 | if(!this.Textures.ContainsKey(imageID)) | ||
347 | { | ||
348 | //not is cache so request from asset server | ||
349 | AssetRequest request = new AssetRequest(); | ||
350 | request.RequestUser = userInfo; | ||
351 | request.RequestAssetID = imageID; | ||
352 | request.IsTextureRequest = true; | ||
353 | this.RequestedTextures.Add(imageID, request); | ||
354 | this._assetServer.RequestAsset(imageID, true); | ||
355 | return; | ||
356 | } | ||
357 | TextureImage imag = this.Textures[imageID]; | ||
358 | AssetRequest req = new AssetRequest(); | ||
359 | req.RequestUser = userInfo; | ||
360 | req.RequestAssetID = imageID; | ||
361 | req.IsTextureRequest = true; | ||
362 | req.ImageInfo = imag; | ||
363 | |||
364 | if(imag.Data.LongLength>600) | ||
365 | { | ||
366 | //over 600 bytes so split up file | ||
367 | req.NumPackets = 1 + (int)(imag.Data.Length-600+999)/1000; | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | req.NumPackets = 1; | ||
372 | } | ||
373 | |||
374 | this.TextureRequests.Add(req); | ||
375 | } | ||
376 | #endregion | ||
377 | |||
378 | } | ||
379 | |||
380 | public class AssetRequest | ||
381 | { | ||
382 | public OpenSimClient RequestUser; | ||
383 | public LLUUID RequestAssetID; | ||
384 | public AssetInfo AssetInf; | ||
385 | public TextureImage ImageInfo; | ||
386 | public LLUUID TransferRequestID; | ||
387 | public long DataPointer = 0; | ||
388 | public int NumPackets = 0; | ||
389 | public int PacketCounter = 0; | ||
390 | public bool IsTextureRequest; | ||
391 | //public bool AssetInCache; | ||
392 | //public int TimeRequested; | ||
393 | |||
394 | public AssetRequest() | ||
395 | { | ||
396 | |||
397 | } | ||
398 | } | ||
399 | |||
400 | public class AssetInfo : AssetBase | ||
401 | { | ||
402 | public AssetInfo() | ||
403 | { | ||
404 | |||
405 | } | ||
406 | |||
407 | public AssetInfo(AssetBase aBase) | ||
408 | { | ||
409 | Data= aBase.Data; | ||
410 | FullID = aBase.FullID; | ||
411 | Type = aBase.Type; | ||
412 | InvType = aBase.InvType; | ||
413 | Name= aBase.Name; | ||
414 | Description = aBase.Description; | ||
415 | } | ||
416 | } | ||
417 | |||
418 | public class TextureImage : AssetBase | ||
419 | { | ||
420 | public TextureImage() | ||
421 | { | ||
422 | |||
423 | } | ||
424 | |||
425 | public TextureImage(AssetBase aBase) | ||
426 | { | ||
427 | Data= aBase.Data; | ||
428 | FullID = aBase.FullID; | ||
429 | Type = aBase.Type; | ||
430 | InvType = aBase.InvType; | ||
431 | Name= aBase.Name; | ||
432 | Description = aBase.Description; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | } | ||
diff --git a/ConvertToPlugins/src/Config.cs b/ConvertToPlugins/src/Config.cs new file mode 100644 index 0000000..c42b80e --- /dev/null +++ b/ConvertToPlugins/src/Config.cs | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.IO; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.world; | ||
35 | |||
36 | namespace OpenSim | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// This class handles connection to the underlying database used for configuration of the region. | ||
40 | /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate | ||
41 | /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from | ||
42 | /// what is hardcoded here and then saved into opensim.yap for future startups. | ||
43 | /// </summary> | ||
44 | |||
45 | |||
46 | public abstract class SimConfig | ||
47 | { | ||
48 | public string RegionName; | ||
49 | |||
50 | public uint RegionLocX; | ||
51 | public uint RegionLocY; | ||
52 | public ulong RegionHandle; | ||
53 | |||
54 | public int IPListenPort; | ||
55 | public string IPListenAddr; | ||
56 | |||
57 | public string AssetURL; | ||
58 | public string AssetSendKey; | ||
59 | |||
60 | public string GridURL; | ||
61 | public string GridSendKey; | ||
62 | |||
63 | public abstract void InitConfig(); | ||
64 | public abstract void LoadFromGrid(); | ||
65 | public abstract World LoadWorld(); | ||
66 | } | ||
67 | |||
68 | public interface ISimConfig | ||
69 | { | ||
70 | SimConfig GetConfigObject(); | ||
71 | } | ||
72 | } | ||
diff --git a/ConvertToPlugins/src/Config/SimConfig/AssemblyInfo.cs b/ConvertToPlugins/src/Config/SimConfig/AssemblyInfo.cs new file mode 100644 index 0000000..96c3e73 --- /dev/null +++ b/ConvertToPlugins/src/Config/SimConfig/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("SimConfig")] | ||
12 | [assembly: AssemblyDescription("")] | ||
13 | [assembly: AssemblyConfiguration("")] | ||
14 | [assembly: AssemblyCompany("")] | ||
15 | [assembly: AssemblyProduct("SimConfig")] | ||
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/ConvertToPlugins/src/Config/SimConfig/Db4SimConfig.cs b/ConvertToPlugins/src/Config/SimConfig/Db4SimConfig.cs new file mode 100644 index 0000000..cc31328 --- /dev/null +++ b/ConvertToPlugins/src/Config/SimConfig/Db4SimConfig.cs | |||
@@ -0,0 +1,146 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using OpenSim; | ||
30 | using OpenSim.world; | ||
31 | using Db4objects.Db4o; | ||
32 | |||
33 | namespace Db40SimConfig | ||
34 | { | ||
35 | public class Db40ConfigPlugin: ISimConfig | ||
36 | { | ||
37 | public SimConfig GetConfigObject() | ||
38 | { | ||
39 | ServerConsole.MainConsole.Instance.WriteLine("Loading Db40Config dll"); | ||
40 | return ( new DbSimConfig()); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | public class DbSimConfig :SimConfig | ||
45 | { | ||
46 | private IObjectContainer db; | ||
47 | |||
48 | public void LoadDefaults() { | ||
49 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); | ||
50 | |||
51 | this.RegionName=ServerConsole.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test"); | ||
52 | this.RegionLocX=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997")); | ||
53 | this.RegionLocY=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996")); | ||
54 | this.IPListenPort=Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000")); | ||
55 | this.IPListenAddr=ServerConsole.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1"); | ||
56 | |||
57 | if(!OpenSim_Main.sim.sandbox) | ||
58 | { | ||
59 | this.AssetURL=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server URL: "); | ||
60 | this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server key: "); | ||
61 | this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server URL: "); | ||
62 | this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server key: "); | ||
63 | } | ||
64 | this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); | ||
65 | } | ||
66 | |||
67 | public override void InitConfig() { | ||
68 | try { | ||
69 | db = Db4oFactory.OpenFile("opensim.yap"); | ||
70 | IObjectSet result = db.Get(typeof(DbSimConfig)); | ||
71 | if(result.Count==1) { | ||
72 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); | ||
73 | foreach (DbSimConfig cfg in result) { | ||
74 | this.RegionName = cfg.RegionName; | ||
75 | this.RegionLocX = cfg.RegionLocX; | ||
76 | this.RegionLocY = cfg.RegionLocY; | ||
77 | this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); | ||
78 | this.IPListenPort = cfg.IPListenPort; | ||
79 | this.IPListenAddr = cfg.IPListenAddr; | ||
80 | this.AssetURL = cfg.AssetURL; | ||
81 | this.AssetSendKey = cfg.AssetSendKey; | ||
82 | this.GridURL = cfg.GridURL; | ||
83 | this.GridSendKey = cfg.GridSendKey; | ||
84 | } | ||
85 | } else { | ||
86 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); | ||
87 | LoadDefaults(); | ||
88 | ServerConsole.MainConsole.Instance.WriteLine("Writing out default settings to local database"); | ||
89 | db.Set(this); | ||
90 | } | ||
91 | } catch(Exception e) { | ||
92 | db.Close(); | ||
93 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); | ||
94 | ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); | ||
95 | } | ||
96 | |||
97 | ServerConsole.MainConsole.Instance.WriteLine("Sim settings loaded:"); | ||
98 | ServerConsole.MainConsole.Instance.WriteLine("Name: " + this.RegionName); | ||
99 | ServerConsole.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | ||
100 | ServerConsole.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); | ||
101 | ServerConsole.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); | ||
102 | ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + OpenSim_Main.sim.sandbox.ToString()); | ||
103 | ServerConsole.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); | ||
104 | ServerConsole.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); | ||
105 | ServerConsole.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); | ||
106 | ServerConsole.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); | ||
107 | } | ||
108 | |||
109 | public override World LoadWorld() | ||
110 | { | ||
111 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world...."); | ||
112 | World blank = new World(); | ||
113 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); | ||
114 | IObjectSet world_result = db.Get(new float[65536]); | ||
115 | if(world_result.Count>0) { | ||
116 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); | ||
117 | blank.LandMap=(float[])world_result.Next(); | ||
118 | } else { | ||
119 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); | ||
120 | HeightmapGenHills hills = new HeightmapGenHills(); | ||
121 | blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); | ||
122 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); | ||
123 | db.Set(blank.LandMap); | ||
124 | db.Commit(); | ||
125 | } | ||
126 | return blank; | ||
127 | } | ||
128 | |||
129 | public override void LoadFromGrid() { | ||
130 | ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); | ||
131 | // TODO: Make this crap work | ||
132 | /* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login"); | ||
133 | WebResponse GridResponse = GridLogin.GetResponse(); | ||
134 | byte[] idata = new byte[(int)GridResponse.ContentLength]; | ||
135 | BinaryReader br = new BinaryReader(GridResponse.GetResponseStream()); | ||
136 | |||
137 | br.Close(); | ||
138 | GridResponse.Close(); | ||
139 | */ | ||
140 | } | ||
141 | |||
142 | public void Shutdown() { | ||
143 | db.Close(); | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/ConvertToPlugins/src/Config/SimConfig/SimConfig.csproj b/ConvertToPlugins/src/Config/SimConfig/SimConfig.csproj new file mode 100644 index 0000000..08f0f24 --- /dev/null +++ b/ConvertToPlugins/src/Config/SimConfig/SimConfig.csproj | |||
@@ -0,0 +1,49 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>SimConfig</RootNamespace> | ||
5 | <AssemblyName>SimConfig</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{B063760D-DB8D-4F64-B6FE-335FAD1E650A}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="Db4objects.Db4o"> | ||
30 | <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <Compile Include="Db4SimConfig.cs" /> | ||
36 | <Compile Include="AssemblyInfo.cs" /> | ||
37 | </ItemGroup> | ||
38 | <ItemGroup> | ||
39 | <ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
40 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
41 | <Name>ServerConsole</Name> | ||
42 | </ProjectReference> | ||
43 | <ProjectReference Include="..\..\Second-server.csproj"> | ||
44 | <Project>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</Project> | ||
45 | <Name>Second-server</Name> | ||
46 | </ProjectReference> | ||
47 | </ItemGroup> | ||
48 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
49 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/Config/SimConfig/SimConfig.sln b/ConvertToPlugins/src/Config/SimConfig/SimConfig.sln new file mode 100644 index 0000000..944d6a8 --- /dev/null +++ b/ConvertToPlugins/src/Config/SimConfig/SimConfig.sln | |||
@@ -0,0 +1,7 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/Config/default.build b/ConvertToPlugins/src/Config/default.build new file mode 100644 index 0000000..2ee0c52 --- /dev/null +++ b/ConvertToPlugins/src/Config/default.build | |||
@@ -0,0 +1,52 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../bin/SimConfig.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="SimConfig/AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-simconfig" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="The default configuration handler" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/SimConfig.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../bin/" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Data" /> | ||
42 | <include name="System.Xml" /> | ||
43 | <include name="ServerConsole.dll" /> | ||
44 | <include name="OpenSim.exe" /> | ||
45 | <include name="Db4objects.Db4o.dll" /> | ||
46 | </references> | ||
47 | <sources basedir="SimConfig/"> | ||
48 | <include name="*.cs" /> | ||
49 | </sources> | ||
50 | </csc> | ||
51 | </target> | ||
52 | </project> | ||
diff --git a/ConvertToPlugins/src/GridInterfaces/AssemblyInfo.cs b/ConvertToPlugins/src/GridInterfaces/AssemblyInfo.cs new file mode 100644 index 0000000..89731a1 --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("GridInterfaces")] | ||
12 | [assembly: AssemblyDescription("")] | ||
13 | [assembly: AssemblyConfiguration("")] | ||
14 | [assembly: AssemblyCompany("")] | ||
15 | [assembly: AssemblyProduct("GridInterfaces")] | ||
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/ConvertToPlugins/src/GridInterfaces/GridInterfaces.csproj b/ConvertToPlugins/src/GridInterfaces/GridInterfaces.csproj new file mode 100644 index 0000000..3284e7f --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/GridInterfaces.csproj | |||
@@ -0,0 +1,40 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>GridInterfaces</RootNamespace> | ||
5 | <AssemblyName>GridInterfaces</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="libsecondlife"> | ||
30 | <HintPath>..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <Compile Include="IAssetServer.cs" /> | ||
36 | <Compile Include="AssemblyInfo.cs" /> | ||
37 | <Compile Include="IGridServer.cs" /> | ||
38 | </ItemGroup> | ||
39 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
40 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/GridInterfaces/GridInterfaces.sln b/ConvertToPlugins/src/GridInterfaces/GridInterfaces.sln new file mode 100644 index 0000000..5ac2b6d --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/GridInterfaces.sln | |||
@@ -0,0 +1,17 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}" | ||
5 | EndProject | ||
6 | Global | ||
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
8 | Debug|Any CPU = Debug|Any CPU | ||
9 | Release|Any CPU = Release|Any CPU | ||
10 | EndGlobalSection | ||
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
12 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
13 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
14 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
15 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
16 | EndGlobalSection | ||
17 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/GridInterfaces/IAssetServer.cs b/ConvertToPlugins/src/GridInterfaces/IAssetServer.cs new file mode 100644 index 0000000..6050a6c --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/IAssetServer.cs | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Net; | ||
29 | using System.Net.Sockets; | ||
30 | using System.IO; | ||
31 | using System.Threading; | ||
32 | using libsecondlife; | ||
33 | |||
34 | |||
35 | namespace OpenSim.GridServers | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Description of IAssetServer. | ||
39 | /// </summary> | ||
40 | |||
41 | public interface IAssetServer | ||
42 | { | ||
43 | void SetReceiver(IAssetReceiver receiver); | ||
44 | void RequestAsset(LLUUID assetID, bool isTexture); | ||
45 | void UpdateAsset(AssetBase asset); | ||
46 | void UploadNewAsset(AssetBase asset); | ||
47 | void SetServerInfo(string ServerUrl, string ServerKey); | ||
48 | } | ||
49 | |||
50 | // could change to delegate? | ||
51 | public interface IAssetReceiver | ||
52 | { | ||
53 | void AssetReceived(AssetBase asset, bool IsTexture); | ||
54 | void AssetNotFound(AssetBase asset); | ||
55 | } | ||
56 | |||
57 | public struct ARequest | ||
58 | { | ||
59 | public LLUUID AssetID; | ||
60 | public bool IsTexture; | ||
61 | } | ||
62 | |||
63 | public class AssetBase | ||
64 | { | ||
65 | public byte[] Data; | ||
66 | public LLUUID FullID; | ||
67 | public sbyte Type; | ||
68 | public sbyte InvType; | ||
69 | public string Name; | ||
70 | public string Description; | ||
71 | |||
72 | public AssetBase() | ||
73 | { | ||
74 | |||
75 | } | ||
76 | } | ||
77 | |||
78 | public interface IAssetPlugin | ||
79 | { | ||
80 | IAssetServer GetAssetServer(); | ||
81 | } | ||
82 | } | ||
diff --git a/ConvertToPlugins/src/GridInterfaces/IGridServer.cs b/ConvertToPlugins/src/GridInterfaces/IGridServer.cs new file mode 100644 index 0000000..fef4c3e --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/IGridServer.cs | |||
@@ -0,0 +1,94 @@ | |||
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 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.IO; | ||
34 | using libsecondlife; | ||
35 | |||
36 | namespace OpenSim.GridServers | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Handles connection to Grid Servers. | ||
40 | /// also Sim to Sim connections? | ||
41 | /// </summary> | ||
42 | |||
43 | |||
44 | |||
45 | |||
46 | public interface IGridServer | ||
47 | { | ||
48 | bool RequestConnection(); | ||
49 | UUIDBlock RequestUUIDBlock(); | ||
50 | void RequestNeighbours(); //should return a array of neighbouring regions | ||
51 | AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
52 | bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
53 | void SetServerInfo(string ServerUrl, string ServerKey); | ||
54 | void AddNewSession(Login session); // only used by local version of grid server | ||
55 | // and didn't use to be part of this interface until we put this in a dll | ||
56 | } | ||
57 | |||
58 | public struct UUIDBlock | ||
59 | { | ||
60 | public LLUUID BlockStart; | ||
61 | public LLUUID BlockEnd; | ||
62 | } | ||
63 | |||
64 | public class AuthenticateResponse | ||
65 | { | ||
66 | public bool Authorised; | ||
67 | public Login LoginInfo; | ||
68 | |||
69 | public AuthenticateResponse() | ||
70 | { | ||
71 | |||
72 | } | ||
73 | |||
74 | } | ||
75 | |||
76 | public class Login | ||
77 | { | ||
78 | public string First = "Test"; | ||
79 | public string Last = "User"; | ||
80 | public LLUUID Agent; | ||
81 | public LLUUID Session; | ||
82 | public LLUUID InventoryFolder; | ||
83 | public LLUUID BaseFolder; | ||
84 | public Login() | ||
85 | { | ||
86 | |||
87 | } | ||
88 | } | ||
89 | |||
90 | public interface IGridPlugin | ||
91 | { | ||
92 | IGridServer GetGridServer(); | ||
93 | } | ||
94 | } | ||
diff --git a/ConvertToPlugins/src/GridInterfaces/default.build b/ConvertToPlugins/src/GridInterfaces/default.build new file mode 100644 index 0000000..f29f108 --- /dev/null +++ b/ConvertToPlugins/src/GridInterfaces/default.build | |||
@@ -0,0 +1,49 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../bin/GridInterfaces.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-gridinterfaces" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="Definitions for OGS interface" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/GridInterfaces.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../bin" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | <include name="libsecondlife.dll" /> | ||
43 | </references> | ||
44 | <sources basedir="./"> | ||
45 | <include name="*.cs" /> | ||
46 | </sources> | ||
47 | </csc> | ||
48 | </target> | ||
49 | </project> | ||
diff --git a/ConvertToPlugins/src/GridServers/LoginServer.cs b/ConvertToPlugins/src/GridServers/LoginServer.cs new file mode 100644 index 0000000..da982e7 --- /dev/null +++ b/ConvertToPlugins/src/GridServers/LoginServer.cs | |||
@@ -0,0 +1,322 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using Nwc.XmlRpc; | ||
29 | using System; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Text; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Threading; | ||
36 | using System.Collections; | ||
37 | using System.Security.Cryptography; | ||
38 | using System.Xml; | ||
39 | using libsecondlife; | ||
40 | using OpenSim; | ||
41 | |||
42 | namespace OpenSim.GridServers | ||
43 | { | ||
44 | |||
45 | /// <summary> | ||
46 | /// When running in local (default) mode , handles client logins. | ||
47 | /// </summary> | ||
48 | public class LoginServer | ||
49 | { | ||
50 | public LoginServer(IGridServer gridServer) | ||
51 | { | ||
52 | _gridServer = gridServer; | ||
53 | } | ||
54 | private Login _login; | ||
55 | private IGridServer _gridServer; | ||
56 | private ushort _loginPort = 8080; | ||
57 | public IPAddress clientAddress = IPAddress.Loopback; | ||
58 | public IPAddress remoteAddress = IPAddress.Any; | ||
59 | private Socket loginServer; | ||
60 | private Random RandomClass = new Random(); | ||
61 | private int NumClients; | ||
62 | private string _defaultResponse; | ||
63 | |||
64 | private string _mpasswd; | ||
65 | private bool _needPasswd=false; | ||
66 | |||
67 | // InitializeLogin: initialize the login | ||
68 | private void InitializeLogin() { | ||
69 | loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | ||
70 | loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); | ||
71 | loginServer.Listen(1); | ||
72 | |||
73 | this._needPasswd=false; | ||
74 | //read in default response string | ||
75 | StreamReader SR; | ||
76 | string lines; | ||
77 | SR=File.OpenText("new-login.dat"); | ||
78 | |||
79 | //lines=SR.ReadLine(); | ||
80 | |||
81 | while(!SR.EndOfStream) | ||
82 | { | ||
83 | lines = SR.ReadLine(); | ||
84 | _defaultResponse += lines; | ||
85 | //lines = SR.ReadLine(); | ||
86 | } | ||
87 | SR.Close(); | ||
88 | this._mpasswd = EncodePassword("testpass"); | ||
89 | } | ||
90 | |||
91 | public void Startup() | ||
92 | { | ||
93 | this.InitializeLogin(); | ||
94 | Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); | ||
95 | runLoginProxy.IsBackground = true; | ||
96 | runLoginProxy.Start(); | ||
97 | } | ||
98 | |||
99 | private void RunLogin() | ||
100 | { | ||
101 | Console.WriteLine("Starting Login Server"); | ||
102 | try | ||
103 | { | ||
104 | for (;;) | ||
105 | { | ||
106 | Socket client = loginServer.Accept(); | ||
107 | IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; | ||
108 | |||
109 | |||
110 | NetworkStream networkStream = new NetworkStream(client); | ||
111 | StreamReader networkReader = new StreamReader(networkStream); | ||
112 | StreamWriter networkWriter = new StreamWriter(networkStream); | ||
113 | |||
114 | try | ||
115 | { | ||
116 | LoginRequest(networkReader, networkWriter); | ||
117 | } | ||
118 | catch (Exception e) | ||
119 | { | ||
120 | Console.WriteLine(e.Message); | ||
121 | } | ||
122 | |||
123 | networkWriter.Close(); | ||
124 | networkReader.Close(); | ||
125 | networkStream.Close(); | ||
126 | |||
127 | client.Close(); | ||
128 | |||
129 | // send any packets queued for injection | ||
130 | |||
131 | } | ||
132 | } | ||
133 | catch (Exception e) | ||
134 | { | ||
135 | Console.WriteLine(e.Message); | ||
136 | Console.WriteLine(e.StackTrace); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | // ProxyLogin: proxy a login request | ||
141 | private void LoginRequest(StreamReader reader, StreamWriter writer) | ||
142 | { | ||
143 | lock(this) | ||
144 | { | ||
145 | string line; | ||
146 | int contentLength = 0; | ||
147 | // read HTTP header | ||
148 | do | ||
149 | { | ||
150 | // read one line of the header | ||
151 | line = reader.ReadLine(); | ||
152 | |||
153 | // check for premature EOF | ||
154 | if (line == null) | ||
155 | throw new Exception("EOF in client HTTP header"); | ||
156 | |||
157 | // look for Content-Length | ||
158 | Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); | ||
159 | if (match.Success) | ||
160 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); | ||
161 | } while (line != ""); | ||
162 | |||
163 | // read the HTTP body into a buffer | ||
164 | char[] content = new char[contentLength]; | ||
165 | reader.Read(content, 0, contentLength); | ||
166 | |||
167 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); | ||
168 | if(request.MethodName == "login_to_simulator") | ||
169 | { | ||
170 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
171 | string first; | ||
172 | string last; | ||
173 | string passwd; | ||
174 | LLUUID Agent; | ||
175 | LLUUID Session; | ||
176 | |||
177 | //get login name | ||
178 | if(requestData.Contains("first")) | ||
179 | { | ||
180 | first = (string)requestData["first"]; | ||
181 | } | ||
182 | else | ||
183 | { | ||
184 | first = "test"; | ||
185 | } | ||
186 | |||
187 | if(requestData.Contains("last")) | ||
188 | { | ||
189 | last = (string)requestData["last"]; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | last = "User"+NumClients.ToString(); | ||
194 | } | ||
195 | |||
196 | if(requestData.Contains("passwd")) | ||
197 | { | ||
198 | passwd = (string)requestData["passwd"]; | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | passwd = "notfound"; | ||
203 | } | ||
204 | |||
205 | if( !Authenticate(first, last, passwd)) | ||
206 | { | ||
207 | // Fail miserably | ||
208 | writer.WriteLine("HTTP/1.0 403 Authentication Forbidden"); | ||
209 | writer.WriteLine(); | ||
210 | return; | ||
211 | } | ||
212 | NumClients++; | ||
213 | |||
214 | //create a agent and session LLUUID | ||
215 | Agent = GetAgentId( first, last ); | ||
216 | int SessionRand = this.RandomClass.Next(1,999); | ||
217 | Session = new LLUUID("aaaabbbb-0200-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); | ||
218 | |||
219 | |||
220 | XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); | ||
221 | Hashtable responseData = (Hashtable)response.Value; | ||
222 | |||
223 | responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort; | ||
224 | responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr; | ||
225 | responseData["agent_id"] = Agent.ToStringHyphenated(); | ||
226 | responseData["session_id"] = Session.ToStringHyphenated(); | ||
227 | ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"]; | ||
228 | Hashtable Inventory1 = (Hashtable)InventoryList[0]; | ||
229 | Hashtable Inventory2 = (Hashtable)InventoryList[1]; | ||
230 | LLUUID BaseFolderID = LLUUID.Random(); | ||
231 | LLUUID InventoryFolderID = LLUUID.Random(); | ||
232 | Inventory2["name"] = "Base"; | ||
233 | Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); | ||
234 | Inventory2["type_default"] =6; | ||
235 | Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
236 | |||
237 | ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"]; | ||
238 | Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; | ||
239 | Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
240 | |||
241 | CustomiseLoginResponse( responseData, first, last ); | ||
242 | |||
243 | this._login = new Login(); | ||
244 | //copy data to login object | ||
245 | _login.First = first; | ||
246 | _login.Last = last; | ||
247 | _login.Agent = Agent; | ||
248 | _login.Session = Session; | ||
249 | _login.BaseFolder = BaseFolderID; | ||
250 | _login.InventoryFolder = InventoryFolderID; | ||
251 | |||
252 | //working on local computer so lets add to the gridserver's list of sessions | ||
253 | this._gridServer.AddNewSession(_login); | ||
254 | |||
255 | // forward the XML-RPC response to the client | ||
256 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
257 | writer.WriteLine("Content-type: text/xml"); | ||
258 | writer.WriteLine(); | ||
259 | |||
260 | XmlTextWriter responseWriter = new XmlTextWriter(writer); | ||
261 | XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); | ||
262 | responseWriter.Close(); | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | writer.WriteLine("HTTP/1.0 403 Authentication Forbidden"); | ||
267 | writer.WriteLine(); | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | |||
272 | protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last ) | ||
273 | { | ||
274 | } | ||
275 | |||
276 | protected virtual LLUUID GetAgentId(string firstName, string lastName) | ||
277 | { | ||
278 | LLUUID Agent; | ||
279 | int AgentRand = this.RandomClass.Next(1,9999); | ||
280 | Agent = new LLUUID("99998888-0100-"+AgentRand.ToString("0000")+"-8ec1-0b1d5cd6aead"); | ||
281 | return Agent; | ||
282 | } | ||
283 | |||
284 | protected virtual bool Authenticate(string first, string last, string passwd) | ||
285 | { | ||
286 | if(this._needPasswd) | ||
287 | { | ||
288 | //every user needs the password to login | ||
289 | string encodedPass = passwd.Remove(0,3); //remove $1$ | ||
290 | if(encodedPass == this._mpasswd) | ||
291 | { | ||
292 | return true; | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | return false; | ||
297 | } | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | //do not need password to login | ||
302 | return true; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | private static string EncodePassword(string passwd) | ||
307 | { | ||
308 | Byte[] originalBytes; | ||
309 | Byte[] encodedBytes; | ||
310 | MD5 md5; | ||
311 | |||
312 | md5 = new MD5CryptoServiceProvider(); | ||
313 | originalBytes = ASCIIEncoding.Default.GetBytes(passwd); | ||
314 | encodedBytes = md5.ComputeHash(originalBytes); | ||
315 | |||
316 | return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower(); | ||
317 | } | ||
318 | |||
319 | } | ||
320 | |||
321 | |||
322 | } | ||
diff --git a/ConvertToPlugins/src/HeightMapGenHills.cs b/ConvertToPlugins/src/HeightMapGenHills.cs new file mode 100644 index 0000000..e7589af --- /dev/null +++ b/ConvertToPlugins/src/HeightMapGenHills.cs | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim | ||
31 | { | ||
32 | public class HeightmapGenHills | ||
33 | { | ||
34 | private Random Rand = new Random(); | ||
35 | private int NumHills; | ||
36 | private float HillMin; | ||
37 | private float HillMax; | ||
38 | private bool Island; | ||
39 | private float[] heightmap; | ||
40 | |||
41 | public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) | ||
42 | { | ||
43 | NumHills = numHills; | ||
44 | HillMin = hillMin; | ||
45 | HillMax = hillMax; | ||
46 | Island = island; | ||
47 | |||
48 | heightmap = new float[256 * 256]; | ||
49 | |||
50 | for (int i = 0; i < numHills; i++) | ||
51 | { | ||
52 | AddHill(); | ||
53 | } | ||
54 | |||
55 | Normalize(); | ||
56 | |||
57 | return heightmap; | ||
58 | } | ||
59 | |||
60 | private void AddHill() | ||
61 | { | ||
62 | float x, y; | ||
63 | float radius = RandomRange(HillMin, HillMax); | ||
64 | |||
65 | if (Island) | ||
66 | { | ||
67 | // Which direction from the center of the map the hill is placed | ||
68 | float theta = RandomRange(0, 6.28f); | ||
69 | |||
70 | // How far from the center of the map to place the hill. The radius | ||
71 | // is subtracted from the range to prevent any part of the hill from | ||
72 | // reaching the edge of the map | ||
73 | float distance = RandomRange(radius / 2.0f, 128.0f - radius); | ||
74 | |||
75 | x = 128.0f + (float)Math.Cos(theta) * distance; | ||
76 | y = 128.0f + (float)Math.Sin(theta) * distance; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | x = RandomRange(-radius, 256.0f + radius); | ||
81 | y = RandomRange(-radius, 256.0f + radius); | ||
82 | } | ||
83 | |||
84 | float radiusSq = radius * radius; | ||
85 | float distSq; | ||
86 | float height; | ||
87 | |||
88 | int xMin = (int)(x - radius) - 1; | ||
89 | int xMax = (int)(x + radius) + 1; | ||
90 | if (xMin < 0) xMin = 0; | ||
91 | if (xMax > 255) xMax = 255; | ||
92 | |||
93 | int yMin = (int)(y - radius) - 1; | ||
94 | int yMax = (int)(y + radius) + 1; | ||
95 | if (yMin < 0) yMin = 0; | ||
96 | if (yMax > 255) yMax = 255; | ||
97 | |||
98 | // Loop through each affected cell and determine the height at that point | ||
99 | for (int v = yMin; v <= yMax; ++v) | ||
100 | { | ||
101 | float fv = (float)v; | ||
102 | |||
103 | for (int h = xMin; h <= xMax; ++h) | ||
104 | { | ||
105 | float fh = (float)h; | ||
106 | |||
107 | // Determine how far from the center of this hill this point is | ||
108 | distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); | ||
109 | height = radiusSq - distSq; | ||
110 | |||
111 | // Don't add negative hill values | ||
112 | if (height > 0.0f) heightmap[h + v * 256] += height; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | private void Normalize() | ||
118 | { | ||
119 | float min = heightmap[0]; | ||
120 | float max = heightmap[0]; | ||
121 | |||
122 | for (int x = 0; x < 256; x++) | ||
123 | { | ||
124 | for (int y = 0; y < 256; y++) | ||
125 | { | ||
126 | if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; | ||
127 | if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | // Avoid a rare divide by zero | ||
132 | if (min != max) | ||
133 | { | ||
134 | for (int x = 0; x < 256; x++) | ||
135 | { | ||
136 | for (int y = 0; y < 256; y++) | ||
137 | { | ||
138 | heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | private float RandomRange(float min, float max) | ||
145 | { | ||
146 | return (float)Rand.NextDouble() * (max - min) + min; | ||
147 | } | ||
148 | } | ||
149 | } | ||
diff --git a/ConvertToPlugins/src/LocalServers/LocalGridServers/AssemblyInfo.cs b/ConvertToPlugins/src/LocalServers/LocalGridServers/AssemblyInfo.cs new file mode 100644 index 0000000..103b49a --- /dev/null +++ b/ConvertToPlugins/src/LocalServers/LocalGridServers/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("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/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGrid.cs b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGrid.cs new file mode 100644 index 0000000..5adce27 --- /dev/null +++ b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGrid.cs | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Threading; | ||
30 | using OpenSim.GridServers; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace LocalGridServers | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | /// | ||
39 | public class LocalGridPlugin : IGridPlugin | ||
40 | { | ||
41 | public LocalGridPlugin() | ||
42 | { | ||
43 | |||
44 | } | ||
45 | |||
46 | public IGridServer GetGridServer() | ||
47 | { | ||
48 | return(new LocalGridServer()); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | public class LocalAssetPlugin : IAssetPlugin | ||
53 | { | ||
54 | public LocalAssetPlugin() | ||
55 | { | ||
56 | |||
57 | } | ||
58 | |||
59 | public IAssetServer GetAssetServer() | ||
60 | { | ||
61 | return(new LocalAssetServer()); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public class LocalAssetServer : IAssetServer | ||
66 | { | ||
67 | private IAssetReceiver _receiver; | ||
68 | private BlockingQueue<ARequest> _assetRequests; | ||
69 | |||
70 | public LocalAssetServer() | ||
71 | { | ||
72 | this._assetRequests = new BlockingQueue<ARequest>(); | ||
73 | ServerConsole.MainConsole.Instance.WriteLine("Local Asset Server class created"); | ||
74 | } | ||
75 | |||
76 | public void SetReceiver(IAssetReceiver receiver) | ||
77 | { | ||
78 | this._receiver = receiver; | ||
79 | } | ||
80 | |||
81 | public void RequestAsset(LLUUID assetID, bool isTexture) | ||
82 | { | ||
83 | ARequest req = new ARequest(); | ||
84 | req.AssetID = assetID; | ||
85 | req.IsTexture = isTexture; | ||
86 | //this._assetRequests.Enqueue(req); | ||
87 | } | ||
88 | |||
89 | public void UpdateAsset(AssetBase asset) | ||
90 | { | ||
91 | |||
92 | } | ||
93 | |||
94 | public void UploadNewAsset(AssetBase asset) | ||
95 | { | ||
96 | |||
97 | } | ||
98 | |||
99 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
100 | { | ||
101 | |||
102 | } | ||
103 | |||
104 | private void RunRequests() | ||
105 | { | ||
106 | while(true) | ||
107 | { | ||
108 | |||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public class LocalGridServer :IGridServer | ||
114 | { | ||
115 | public List<Login> Sessions = new List<Login>(); | ||
116 | |||
117 | public LocalGridServer() | ||
118 | { | ||
119 | Sessions = new List<Login>(); | ||
120 | ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created"); | ||
121 | } | ||
122 | |||
123 | public bool RequestConnection() | ||
124 | { | ||
125 | return true; | ||
126 | } | ||
127 | public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | ||
128 | { | ||
129 | //we are running local | ||
130 | AuthenticateResponse user = new AuthenticateResponse(); | ||
131 | |||
132 | lock(this.Sessions) | ||
133 | { | ||
134 | |||
135 | for(int i = 0; i < Sessions.Count; i++) | ||
136 | { | ||
137 | if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID)) | ||
138 | { | ||
139 | user.Authorised = true; | ||
140 | user.LoginInfo = Sessions[i]; | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | return(user); | ||
145 | } | ||
146 | |||
147 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | ||
148 | { | ||
149 | return(true); | ||
150 | } | ||
151 | |||
152 | public UUIDBlock RequestUUIDBlock() | ||
153 | { | ||
154 | UUIDBlock uuidBlock = new UUIDBlock(); | ||
155 | return(uuidBlock); | ||
156 | } | ||
157 | |||
158 | public void RequestNeighbours() | ||
159 | { | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
164 | { | ||
165 | |||
166 | } | ||
167 | /// <summary> | ||
168 | /// used by the local login server to inform us of new sessions | ||
169 | /// </summary> | ||
170 | /// <param name="session"></param> | ||
171 | public void AddNewSession(Login session) | ||
172 | { | ||
173 | lock(this.Sessions) | ||
174 | { | ||
175 | this.Sessions.Add(session); | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | |||
180 | public class BlockingQueue< T > { | ||
181 | private Queue< T > _queue = new Queue< T >(); | ||
182 | private object _queueSync = new object(); | ||
183 | |||
184 | public void Enqueue(T value) | ||
185 | { | ||
186 | lock(_queueSync) | ||
187 | { | ||
188 | _queue.Enqueue(value); | ||
189 | Monitor.Pulse(_queueSync); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | public T Dequeue() | ||
194 | { | ||
195 | lock(_queueSync) | ||
196 | { | ||
197 | if( _queue.Count < 1) | ||
198 | Monitor.Wait(_queueSync); | ||
199 | |||
200 | return _queue.Dequeue(); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | } | ||
diff --git a/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.csproj b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.csproj new file mode 100644 index 0000000..dc9c566 --- /dev/null +++ b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.csproj | |||
@@ -0,0 +1,49 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>LocalGridServers</RootNamespace> | ||
5 | <AssemblyName>LocalGridServers</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{D7F0395B-FADC-4936-80A0-D95AACE92F62}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="libsecondlife"> | ||
30 | <HintPath>..\..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <Compile Include="LocalGrid.cs" /> | ||
36 | <Compile Include="AssemblyInfo.cs" /> | ||
37 | </ItemGroup> | ||
38 | <ItemGroup> | ||
39 | <ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
40 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
41 | <Name>ServerConsole</Name> | ||
42 | </ProjectReference> | ||
43 | <ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj"> | ||
44 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
45 | <Name>GridInterfaces</Name> | ||
46 | </ProjectReference> | ||
47 | </ItemGroup> | ||
48 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
49 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.sln b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.sln new file mode 100644 index 0000000..659e1d5 --- /dev/null +++ b/ConvertToPlugins/src/LocalServers/LocalGridServers/LocalGridServers.sln | |||
@@ -0,0 +1,7 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/LocalServers/default.build b/ConvertToPlugins/src/LocalServers/default.build new file mode 100644 index 0000000..06bfcaa --- /dev/null +++ b/ConvertToPlugins/src/LocalServers/default.build | |||
@@ -0,0 +1,51 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../bin/LocalGridServers.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="LocalGridServers/AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-localservers" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="local grid servers" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/LocalGridServers.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../bin" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | <include name="libsecondlife.dll" /> | ||
43 | <include name="GridInterfaces.dll" /> | ||
44 | <include name="ServerConsole.dll" /> | ||
45 | </references> | ||
46 | <sources basedir="LocalGridServers/"> | ||
47 | <include name="*.cs" /> | ||
48 | </sources> | ||
49 | </csc> | ||
50 | </target> | ||
51 | </project> | ||
diff --git a/ConvertToPlugins/src/Main.cs b/ConvertToPlugins/src/Main.cs new file mode 100644 index 0000000..4fc7d54 --- /dev/null +++ b/ConvertToPlugins/src/Main.cs | |||
@@ -0,0 +1,317 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | |||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Text; | ||
32 | using System.IO; | ||
33 | using System.Threading; | ||
34 | using System.Net; | ||
35 | using System.Net.Sockets; | ||
36 | using System.Timers; | ||
37 | using System.Reflection; | ||
38 | using System.Collections; | ||
39 | using System.Collections.Generic; | ||
40 | using libsecondlife; | ||
41 | using libsecondlife.Packets; | ||
42 | using OpenSim.world; | ||
43 | using OpenSim.GridServers; | ||
44 | using OpenSim.Assets; | ||
45 | using ServerConsole; | ||
46 | using PhysicsSystem; | ||
47 | |||
48 | namespace OpenSim | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Description of MainForm. | ||
52 | /// </summary> | ||
53 | public class OpenSim_Main | ||
54 | { | ||
55 | public static OpenSim_Main sim; | ||
56 | public static SimConfig cfg; | ||
57 | public static World local_world; | ||
58 | public static Grid gridServers; | ||
59 | |||
60 | public static Socket Server; | ||
61 | private static IPEndPoint ServerIncoming; | ||
62 | private static byte[] RecvBuffer = new byte[4096]; | ||
63 | private byte[] ZeroBuffer = new byte[8192]; | ||
64 | private static IPEndPoint ipeSender; | ||
65 | private static EndPoint epSender; | ||
66 | private static AsyncCallback ReceivedData; | ||
67 | |||
68 | public AssetCache assetCache; | ||
69 | public DateTime startuptime; | ||
70 | public Dictionary<EndPoint, OpenSimClient> ClientThreads = new Dictionary<EndPoint, OpenSimClient>(); | ||
71 | private PhysicsManager physManager; | ||
72 | private System.Timers.Timer timer1 = new System.Timers.Timer(); | ||
73 | private string ConfigDll = "SimConfig.dll"; | ||
74 | public bool sandbox = false; | ||
75 | public bool loginserver = false; | ||
76 | |||
77 | [STAThread] | ||
78 | public static void Main( string[] args ) | ||
79 | { | ||
80 | Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); | ||
81 | Console.WriteLine("Starting...\n"); | ||
82 | ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local,"",0); | ||
83 | |||
84 | sim = new OpenSim_Main(); | ||
85 | |||
86 | for (int i = 0; i < args.Length; i++) | ||
87 | { | ||
88 | if(args[i] == "-sandbox") | ||
89 | { | ||
90 | sim.sandbox = true; | ||
91 | } | ||
92 | if(args[i] == "-loginserver") | ||
93 | { | ||
94 | sim.loginserver = true; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | OpenSim_Main.gridServers = new Grid(); | ||
99 | if(sim.sandbox) | ||
100 | { | ||
101 | OpenSim_Main.gridServers.AssetDll = "LocalGridServers.dll"; | ||
102 | OpenSim_Main.gridServers.GridDll = "LocalGridServers.dll"; | ||
103 | OpenSim_Main.gridServers.LoadPlugins(); | ||
104 | ServerConsole.MainConsole.Instance.WriteLine("Starting in Sandbox mode"); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | OpenSim_Main.gridServers.AssetDll = "RemoteGridServers.dll"; | ||
109 | OpenSim_Main.gridServers.GridDll = "RemoteGridServers.dll"; | ||
110 | OpenSim_Main.gridServers.LoadPlugins(); | ||
111 | ServerConsole.MainConsole.Instance.WriteLine("Starting in Grid mode"); | ||
112 | } | ||
113 | |||
114 | if(sim.loginserver && sim.sandbox) | ||
115 | { | ||
116 | LoginServer loginServer = new LoginServer(OpenSim_Main.gridServers.GridServer); | ||
117 | loginServer.Startup(); | ||
118 | } | ||
119 | sim.assetCache = new AssetCache(OpenSim_Main.gridServers.AssetServer); | ||
120 | |||
121 | sim.Startup(); | ||
122 | |||
123 | while(true) { | ||
124 | ServerConsole.MainConsole.Instance.MainConsolePrompt(); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | private OpenSim_Main() { | ||
129 | } | ||
130 | |||
131 | private void Startup() { | ||
132 | startuptime=DateTime.Now; | ||
133 | timer1.Enabled = true; | ||
134 | timer1.Interval = 100; | ||
135 | timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); | ||
136 | |||
137 | // We check our local database first, then the grid for config options | ||
138 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); | ||
139 | cfg = this.LoadConfigDll(this.ConfigDll); | ||
140 | cfg.InitConfig(); | ||
141 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver"); | ||
142 | cfg.LoadFromGrid(); | ||
143 | |||
144 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString()); | ||
145 | ServerConsole.MainConsole.Instance.WriteLine("Initialising world"); | ||
146 | local_world = cfg.LoadWorld(); | ||
147 | |||
148 | this.physManager = new PhysicsSystem.PhysicsManager(); | ||
149 | this.physManager.LoadPlugins(); | ||
150 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system"); | ||
151 | local_world.PhysScene = this.physManager.GetPhysicsScene("PhysX"); //should be reading from the config file what physics engine to use | ||
152 | local_world.PhysScene.SetTerrain(local_world.LandMap); | ||
153 | OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey); | ||
154 | OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey); | ||
155 | |||
156 | MainServerListener(); | ||
157 | |||
158 | } | ||
159 | |||
160 | private SimConfig LoadConfigDll(string dllName) | ||
161 | { | ||
162 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
163 | SimConfig config = null; | ||
164 | |||
165 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
166 | { | ||
167 | if (pluginType.IsPublic) | ||
168 | { | ||
169 | if (!pluginType.IsAbstract) | ||
170 | { | ||
171 | Type typeInterface = pluginType.GetInterface("ISimConfig", true); | ||
172 | |||
173 | if (typeInterface != null) | ||
174 | { | ||
175 | ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
176 | config = plug.GetConfigObject(); | ||
177 | break; | ||
178 | } | ||
179 | |||
180 | typeInterface = null; | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | pluginAssembly = null; | ||
185 | return config; | ||
186 | } | ||
187 | |||
188 | private void OnReceivedData(IAsyncResult result) { | ||
189 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
190 | epSender = (EndPoint)ipeSender; | ||
191 | Packet packet = null; | ||
192 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
193 | int packetEnd = numBytes - 1; | ||
194 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
195 | |||
196 | // This is either a new client or a packet to send to an old one | ||
197 | if(ClientThreads.ContainsKey(epSender)) { | ||
198 | ClientThreads[epSender].InPacket(packet); | ||
199 | } else if( packet.Type == PacketType.UseCircuitCode ) { // new client | ||
200 | OpenSimClient newuser = new OpenSimClient(epSender,(UseCircuitCodePacket)packet); | ||
201 | ClientThreads.Add(epSender, newuser); | ||
202 | } else { // invalid client | ||
203 | Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); | ||
204 | } | ||
205 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
206 | } | ||
207 | |||
208 | private void MainServerListener() { | ||
209 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started"); | ||
210 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort); | ||
211 | |||
212 | ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort); | ||
213 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
214 | Server.Bind(ServerIncoming); | ||
215 | |||
216 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); | ||
217 | |||
218 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
219 | epSender = (EndPoint) ipeSender; | ||
220 | ReceivedData = new AsyncCallback(this.OnReceivedData); | ||
221 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
222 | |||
223 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Listening..."); | ||
224 | |||
225 | } | ||
226 | |||
227 | public static void Shutdown() { | ||
228 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing all threads"); | ||
229 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing listener thread"); | ||
230 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients"); | ||
231 | // IMPLEMENT THIS | ||
232 | ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); | ||
233 | ServerConsole.MainConsole.Instance.Close(); | ||
234 | Environment.Exit(0); | ||
235 | } | ||
236 | |||
237 | void Timer1Tick( object sender, System.EventArgs e ) | ||
238 | { | ||
239 | |||
240 | local_world.Update(); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | public class Grid | ||
245 | { | ||
246 | public IAssetServer AssetServer; | ||
247 | public IGridServer GridServer; | ||
248 | public string AssetDll = ""; | ||
249 | public string GridDll = ""; | ||
250 | |||
251 | public Grid() | ||
252 | { | ||
253 | } | ||
254 | |||
255 | public void LoadPlugins() | ||
256 | { | ||
257 | this.AssetServer = this.LoadAssetDll(this.AssetDll); | ||
258 | this.GridServer = this.LoadGridDll(this.GridDll); | ||
259 | } | ||
260 | |||
261 | private IAssetServer LoadAssetDll(string dllName) | ||
262 | { | ||
263 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
264 | IAssetServer server = null; | ||
265 | |||
266 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
267 | { | ||
268 | if (pluginType.IsPublic) | ||
269 | { | ||
270 | if (!pluginType.IsAbstract) | ||
271 | { | ||
272 | Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); | ||
273 | |||
274 | if (typeInterface != null) | ||
275 | { | ||
276 | IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
277 | server = plug.GetAssetServer(); | ||
278 | break; | ||
279 | } | ||
280 | |||
281 | typeInterface = null; | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | pluginAssembly = null; | ||
286 | return server; | ||
287 | } | ||
288 | |||
289 | private IGridServer LoadGridDll(string dllName) | ||
290 | { | ||
291 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
292 | IGridServer server = null; | ||
293 | |||
294 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
295 | { | ||
296 | if (pluginType.IsPublic) | ||
297 | { | ||
298 | if (!pluginType.IsAbstract) | ||
299 | { | ||
300 | Type typeInterface = pluginType.GetInterface("IGridPlugin", true); | ||
301 | |||
302 | if (typeInterface != null) | ||
303 | { | ||
304 | IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
305 | server = plug.GetGridServer(); | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | typeInterface = null; | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | pluginAssembly = null; | ||
314 | return server; | ||
315 | } | ||
316 | } | ||
317 | } | ||
diff --git a/ConvertToPlugins/src/OpenSimClient.cs b/ConvertToPlugins/src/OpenSimClient.cs new file mode 100644 index 0000000..8021d59 --- /dev/null +++ b/ConvertToPlugins/src/OpenSimClient.cs | |||
@@ -0,0 +1,387 @@ | |||
1 | /* | ||
2 | Copyright (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 | |||
27 | using System; | ||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using libsecondlife.Packets; | ||
32 | using System.Net; | ||
33 | using System.Net.Sockets; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | using OpenSim.GridServers; | ||
38 | |||
39 | namespace OpenSim | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Handles new client connections | ||
43 | /// Constructor takes a single Packet and authenticates everything | ||
44 | /// </summary> | ||
45 | public class OpenSimClient { | ||
46 | |||
47 | public LLUUID AgentID; | ||
48 | public LLUUID SessionID; | ||
49 | public uint CircuitCode; | ||
50 | public world.Avatar ClientAvatar; | ||
51 | private UseCircuitCodePacket cirpack; | ||
52 | private Thread ClientThread; | ||
53 | public EndPoint userEP; | ||
54 | private BlockingQueue<QueItem> PacketQueue; | ||
55 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
56 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
57 | private System.Timers.Timer AckTimer; | ||
58 | private uint Sequence = 0; | ||
59 | private object SequenceLock = new object(); | ||
60 | private const int MAX_APPENDED_ACKS = 10; | ||
61 | private const int RESEND_TIMEOUT = 4000; | ||
62 | private const int MAX_SEQUENCE = 0xFFFFFF; | ||
63 | |||
64 | public void ack_pack(Packet Pack) { | ||
65 | //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); | ||
66 | //ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
67 | //ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
68 | //ack_it.Packets[0].ID = Pack.Header.ID; | ||
69 | //ack_it.Header.Reliable = false; | ||
70 | |||
71 | //OutPacket(ack_it); | ||
72 | |||
73 | if (Pack.Header.Reliable) { | ||
74 | lock (PendingAcks) { | ||
75 | uint sequence = (uint)Pack.Header.Sequence; | ||
76 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public void ProcessInPacket(Packet Pack) { | ||
82 | ack_pack(Pack); | ||
83 | switch(Pack.Type) { | ||
84 | case PacketType.CompleteAgentMovement: | ||
85 | ClientAvatar.CompleteMovement(OpenSim_Main.local_world); | ||
86 | ClientAvatar.SendInitialPosition(); | ||
87 | break; | ||
88 | case PacketType.RegionHandshakeReply: | ||
89 | OpenSim_Main.local_world.SendLayerData(this); | ||
90 | break; | ||
91 | case PacketType.AgentWearablesRequest: | ||
92 | ClientAvatar.SendInitialAppearance(); | ||
93 | break; | ||
94 | case PacketType.ObjectAdd: | ||
95 | OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this); | ||
96 | break; | ||
97 | case PacketType.TransferRequest: | ||
98 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
99 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
100 | OpenSim_Main.sim.assetCache.AddAssetRequest(this, transfer); | ||
101 | break; | ||
102 | case PacketType.AgentUpdate: | ||
103 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); | ||
104 | break; | ||
105 | case PacketType.LogoutRequest: | ||
106 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | ||
107 | lock(OpenSim_Main.local_world.Entities) { | ||
108 | OpenSim_Main.local_world.Entities.Remove(this.AgentID); | ||
109 | } | ||
110 | //need to do other cleaning up here too | ||
111 | OpenSim_Main.gridServers.GridServer.LogoutSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); | ||
112 | this.ClientThread.Abort(); | ||
113 | break; | ||
114 | case PacketType.ChatFromViewer: | ||
115 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
116 | if(Helpers.FieldToString(inchatpack.ChatData.Message)=="") break; | ||
117 | |||
118 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
119 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
120 | reply.ChatData.Audible = 1; | ||
121 | reply.ChatData.Message = inchatpack.ChatData.Message; | ||
122 | reply.ChatData.ChatType = 1; | ||
123 | reply.ChatData.SourceType = 1; | ||
124 | reply.ChatData.Position = this.ClientAvatar.position; | ||
125 | reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); | ||
126 | reply.ChatData.OwnerID = this.AgentID; | ||
127 | reply.ChatData.SourceID = this.AgentID; | ||
128 | foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { | ||
129 | client.OutPacket(reply); | ||
130 | } | ||
131 | break; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | private void ResendUnacked() | ||
136 | { | ||
137 | int now = Environment.TickCount; | ||
138 | |||
139 | lock (NeedAck) | ||
140 | { | ||
141 | foreach (Packet packet in NeedAck.Values) | ||
142 | { | ||
143 | if (now - packet.TickCount > RESEND_TIMEOUT) | ||
144 | { | ||
145 | ServerConsole.MainConsole.Instance.WriteLine("Resending " + packet.Type.ToString() + " packet, " + | ||
146 | (now - packet.TickCount) + "ms have passed"); | ||
147 | |||
148 | packet.Header.Resent = true; | ||
149 | OutPacket(packet); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | private void SendAcks() | ||
156 | { | ||
157 | lock (PendingAcks) | ||
158 | { | ||
159 | if (PendingAcks.Count > 0) | ||
160 | { | ||
161 | if (PendingAcks.Count > 250) | ||
162 | { | ||
163 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | ||
164 | ServerConsole.MainConsole.Instance.WriteLine("Too many ACKs queued up!"); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | ServerConsole.MainConsole.Instance.WriteLine("Sending PacketAck"); | ||
169 | |||
170 | |||
171 | int i = 0; | ||
172 | PacketAckPacket acks = new PacketAckPacket(); | ||
173 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | ||
174 | |||
175 | foreach (uint ack in PendingAcks.Values) | ||
176 | { | ||
177 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
178 | acks.Packets[i].ID = ack; | ||
179 | i++; | ||
180 | } | ||
181 | |||
182 | acks.Header.Reliable = false; | ||
183 | OutPacket(acks); | ||
184 | |||
185 | PendingAcks.Clear(); | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | |||
190 | private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
191 | { | ||
192 | SendAcks(); | ||
193 | ResendUnacked(); | ||
194 | } | ||
195 | |||
196 | public void ProcessOutPacket(Packet Pack) { | ||
197 | |||
198 | // Keep track of when this packet was sent out | ||
199 | Pack.TickCount = Environment.TickCount; | ||
200 | |||
201 | if (!Pack.Header.Resent) | ||
202 | { | ||
203 | // Set the sequence number | ||
204 | lock (SequenceLock) | ||
205 | { | ||
206 | if (Sequence >= MAX_SEQUENCE) | ||
207 | Sequence = 1; | ||
208 | else | ||
209 | Sequence++; | ||
210 | Pack.Header.Sequence = Sequence; | ||
211 | } | ||
212 | |||
213 | if (Pack.Header.Reliable) //DIRTY HACK | ||
214 | { | ||
215 | lock (NeedAck) | ||
216 | { | ||
217 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | ||
218 | { | ||
219 | NeedAck.Add(Pack.Header.Sequence, Pack); | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
224 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
225 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
230 | // delivery to fail | ||
231 | if (!Pack.Header.Resent) | ||
232 | { | ||
233 | // Append any ACKs that need to be sent out to this packet | ||
234 | lock (PendingAcks) | ||
235 | { | ||
236 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | ||
237 | Pack.Type != PacketType.PacketAck && | ||
238 | Pack.Type != PacketType.LogoutRequest) | ||
239 | { | ||
240 | Pack.Header.AckList = new uint[PendingAcks.Count]; | ||
241 | int i = 0; | ||
242 | |||
243 | foreach (uint ack in PendingAcks.Values) | ||
244 | { | ||
245 | Pack.Header.AckList[i] = ack; | ||
246 | i++; | ||
247 | } | ||
248 | |||
249 | PendingAcks.Clear(); | ||
250 | Pack.Header.AppendedAcks = true; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | |||
258 | byte[] ZeroOutBuffer = new byte[4096]; | ||
259 | byte[] sendbuffer; | ||
260 | sendbuffer = Pack.ToBytes(); | ||
261 | |||
262 | try { | ||
263 | if (Pack.Header.Zerocoded) { | ||
264 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
265 | OpenSim_Main.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None,userEP); | ||
266 | } else { | ||
267 | OpenSim_Main.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None,userEP); | ||
268 | } | ||
269 | } catch (Exception) { | ||
270 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); | ||
271 | ClientThread.Abort(); | ||
272 | } | ||
273 | |||
274 | } | ||
275 | |||
276 | public void InPacket(Packet NewPack) { | ||
277 | // Handle appended ACKs | ||
278 | if (NewPack.Header.AppendedAcks) | ||
279 | { | ||
280 | lock (NeedAck) | ||
281 | { | ||
282 | foreach (uint ack in NewPack.Header.AckList) | ||
283 | { | ||
284 | NeedAck.Remove(ack); | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | |||
289 | // Handle PacketAck packets | ||
290 | if (NewPack.Type == PacketType.PacketAck) | ||
291 | { | ||
292 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; | ||
293 | |||
294 | lock (NeedAck) | ||
295 | { | ||
296 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
297 | { | ||
298 | NeedAck.Remove(block.ID); | ||
299 | } | ||
300 | } | ||
301 | } else if( ( NewPack.Type == PacketType.StartPingCheck ) ) { | ||
302 | //reply to pingcheck | ||
303 | libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; | ||
304 | libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | ||
305 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
306 | OutPacket(endPing); | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | QueItem item = new QueItem(); | ||
311 | item.Packet = NewPack; | ||
312 | item.Incoming = true; | ||
313 | this.PacketQueue.Enqueue(item); | ||
314 | } | ||
315 | |||
316 | } | ||
317 | |||
318 | public void OutPacket(Packet NewPack) { | ||
319 | QueItem item = new QueItem(); | ||
320 | item.Packet = NewPack; | ||
321 | item.Incoming = false; | ||
322 | this.PacketQueue.Enqueue(item); | ||
323 | } | ||
324 | |||
325 | public OpenSimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack) { | ||
326 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); | ||
327 | cirpack = initialcirpack; | ||
328 | userEP = remoteEP; | ||
329 | PacketQueue = new BlockingQueue<QueItem>(); | ||
330 | AckTimer = new System.Timers.Timer(500); | ||
331 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); | ||
332 | AckTimer.Start(); | ||
333 | |||
334 | ClientThread = new Thread(new ThreadStart(AuthUser)); | ||
335 | ClientThread.IsBackground = true; | ||
336 | ClientThread.Start(); | ||
337 | } | ||
338 | |||
339 | private void ClientLoop() { | ||
340 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); | ||
341 | while(true) { | ||
342 | QueItem nextPacket = PacketQueue.Dequeue(); | ||
343 | if(nextPacket.Incoming) | ||
344 | { | ||
345 | //is a incoming packet | ||
346 | ProcessInPacket(nextPacket.Packet); | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | //is a out going packet | ||
351 | ProcessOutPacket(nextPacket.Packet); | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | |||
356 | private void InitNewClient() { | ||
357 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); | ||
358 | OpenSim_Main.local_world.AddViewerAgent(this); | ||
359 | world.Entity tempent=OpenSim_Main.local_world.Entities[this.AgentID]; | ||
360 | this.ClientAvatar=(world.Avatar)tempent; | ||
361 | } | ||
362 | |||
363 | private void AuthUser() | ||
364 | { | ||
365 | AuthenticateResponse sessionInfo = OpenSim_Main.gridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); | ||
366 | if(!sessionInfo.Authorised) | ||
367 | { | ||
368 | //session/circuit not authorised | ||
369 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); | ||
370 | ClientThread.Abort(); | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); | ||
375 | //session is authorised | ||
376 | this.AgentID=cirpack.CircuitCode.ID; | ||
377 | this.SessionID=cirpack.CircuitCode.SessionID; | ||
378 | this.CircuitCode=cirpack.CircuitCode.Code; | ||
379 | InitNewClient(); | ||
380 | this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; | ||
381 | this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; | ||
382 | ClientLoop(); | ||
383 | } | ||
384 | } | ||
385 | } | ||
386 | |||
387 | } | ||
diff --git a/ConvertToPlugins/src/OpenSimConsole.cs b/ConvertToPlugins/src/OpenSimConsole.cs new file mode 100644 index 0000000..7d8563f --- /dev/null +++ b/ConvertToPlugins/src/OpenSimConsole.cs | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Threading; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using libsecondlife; | ||
35 | using libsecondlife.Packets; | ||
36 | using ServerConsole; | ||
37 | |||
38 | namespace OpenSim | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Description of ServerConsole. | ||
42 | /// </summary> | ||
43 | public class MServerConsole : ConsoleBase | ||
44 | { | ||
45 | |||
46 | private ConsoleType ConsType; | ||
47 | StreamWriter Log; | ||
48 | |||
49 | |||
50 | // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! | ||
51 | // constype - the type of console to use (see enum ConsoleType) | ||
52 | // sparam - depending on the console type: | ||
53 | // TCP - the IP to bind to (127.0.0.1 if blank) | ||
54 | // Local - param ignored | ||
55 | // SimChat - the AgentID of this sim's admin | ||
56 | // and for the iparam: | ||
57 | // TCP - the port to bind to | ||
58 | // Local - param ignored | ||
59 | // SimChat - the chat channel to accept commands from | ||
60 | public MServerConsole(ConsoleType constype, string sparam, int iparam) { | ||
61 | ConsType = constype; | ||
62 | switch(constype) { | ||
63 | case ConsoleType.Local: | ||
64 | Console.WriteLine("ServerConsole.cs - creating new local console"); | ||
65 | Console.WriteLine("Logs will be saved to current directory in opensim-console.log"); | ||
66 | Log=File.AppendText("opensim-console.log"); | ||
67 | Log.WriteLine("========================================================================"); | ||
68 | //Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString()); | ||
69 | break; | ||
70 | case ConsoleType.TCP: | ||
71 | break; | ||
72 | case ConsoleType.SimChat: | ||
73 | break; | ||
74 | |||
75 | default: | ||
76 | Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!"); | ||
77 | break; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public override void Close() { | ||
82 | Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString()); | ||
83 | Log.Close(); | ||
84 | } | ||
85 | |||
86 | // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here | ||
87 | public override void WriteLine(string Line) { | ||
88 | Log.WriteLine(Line); | ||
89 | Console.WriteLine(Line); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | public override string ReadLine() { | ||
94 | string TempStr=Console.ReadLine(); | ||
95 | Log.WriteLine(TempStr); | ||
96 | return TempStr; | ||
97 | } | ||
98 | |||
99 | public override int Read() { | ||
100 | int TempInt= Console.Read(); | ||
101 | Log.Write((char)TempInt); | ||
102 | return TempInt; | ||
103 | } | ||
104 | |||
105 | public override void Write(string Line) { | ||
106 | Console.Write(Line); | ||
107 | Log.Write(Line); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | // Displays a command prompt and waits for the user to enter a string, then returns that string | ||
112 | public override string CmdPrompt(string prompt) { | ||
113 | this.Write(prompt); | ||
114 | return this.ReadLine(); | ||
115 | } | ||
116 | |||
117 | // Displays a command prompt and returns a default value if the user simply presses enter | ||
118 | public override string CmdPrompt(string prompt, string defaultresponse) { | ||
119 | string temp=CmdPrompt(prompt); | ||
120 | if(temp=="") { | ||
121 | return defaultresponse; | ||
122 | } else { | ||
123 | return temp; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | ||
128 | public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) { | ||
129 | bool itisdone=false; | ||
130 | string temp=CmdPrompt(prompt,defaultresponse); | ||
131 | while(itisdone==false) { | ||
132 | if((temp==OptionA) || (temp==OptionB)) { | ||
133 | itisdone=true; | ||
134 | } else { | ||
135 | this.WriteLine("Valid options are " + OptionA + " or " + OptionB); | ||
136 | temp=CmdPrompt(prompt,defaultresponse); | ||
137 | } | ||
138 | } | ||
139 | return temp; | ||
140 | } | ||
141 | |||
142 | // Runs a command with a number of parameters | ||
143 | public override Object RunCmd(string Cmd, string[] cmdparams) { | ||
144 | switch(Cmd) { | ||
145 | case "help": | ||
146 | this.WriteLine("show users - show info about connected users"); | ||
147 | this.WriteLine("shutdown - disconnect all clients and shutdown"); | ||
148 | break; | ||
149 | |||
150 | case "show": | ||
151 | ShowCommands(cmdparams[0]); | ||
152 | break; | ||
153 | |||
154 | case "shutdown": | ||
155 | OpenSim_Main.Shutdown(); | ||
156 | break; | ||
157 | } | ||
158 | return null; | ||
159 | } | ||
160 | |||
161 | // Shows data about something | ||
162 | public override void ShowCommands(string ShowWhat) { | ||
163 | switch(ShowWhat) { | ||
164 | case "uptime": | ||
165 | this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString()); | ||
166 | this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.startuptime).ToString()); | ||
167 | break; | ||
168 | case "users": | ||
169 | OpenSim.world.Avatar TempAv; | ||
170 | this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); | ||
171 | foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { | ||
172 | TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; | ||
173 | this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); | ||
174 | } | ||
175 | break; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | // Displays a prompt to the user and then runs the command they entered | ||
180 | public override void MainConsolePrompt() { | ||
181 | string[] tempstrarray; | ||
182 | string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); | ||
183 | tempstrarray = tempstr.Split(' '); | ||
184 | string cmd=tempstrarray[0]; | ||
185 | Array.Reverse(tempstrarray); | ||
186 | Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1); | ||
187 | Array.Reverse(tempstrarray); | ||
188 | string[] cmdparams=(string[])tempstrarray; | ||
189 | RunCmd(cmd,cmdparams); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | |||
194 | |||
diff --git a/ConvertToPlugins/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs new file mode 100644 index 0000000..0fa7d6e --- /dev/null +++ b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("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/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs new file mode 100644 index 0000000..f7c33e8 --- /dev/null +++ b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs | |||
@@ -0,0 +1,241 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Threading; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using System.IO; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.GridServers; | ||
35 | |||
36 | namespace RemoteGridServers | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// | ||
40 | /// </summary> | ||
41 | /// | ||
42 | |||
43 | public class RemoteGridPlugin : IGridPlugin | ||
44 | { | ||
45 | public RemoteGridPlugin() | ||
46 | { | ||
47 | |||
48 | } | ||
49 | |||
50 | public IGridServer GetGridServer() | ||
51 | { | ||
52 | return(new RemoteGridServer()); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public class RemoteAssetPlugin : IAssetPlugin | ||
57 | { | ||
58 | public RemoteAssetPlugin() | ||
59 | { | ||
60 | |||
61 | } | ||
62 | |||
63 | public IAssetServer GetAssetServer() | ||
64 | { | ||
65 | return(new RemoteAssetServer()); | ||
66 | } | ||
67 | } | ||
68 | public class RemoteGridServer :IGridServer | ||
69 | { | ||
70 | private string GridServerUrl; | ||
71 | private string GridSendKey; | ||
72 | |||
73 | public RemoteGridServer() | ||
74 | { | ||
75 | ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created"); | ||
76 | } | ||
77 | |||
78 | public bool RequestConnection() | ||
79 | { | ||
80 | return true; | ||
81 | } | ||
82 | public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | ||
83 | { | ||
84 | AuthenticateResponse user = new AuthenticateResponse(); | ||
85 | |||
86 | WebRequest CheckSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/exists"); | ||
87 | WebResponse GridResponse = CheckSession.GetResponse(); | ||
88 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); | ||
89 | String grTest = sr.ReadLine(); | ||
90 | sr.Close(); | ||
91 | GridResponse.Close(); | ||
92 | if(String.IsNullOrEmpty(grTest) || grTest.Equals("1")) | ||
93 | { | ||
94 | // YAY! Valid login | ||
95 | user.Authorised = true; | ||
96 | user.LoginInfo = new Login(); | ||
97 | user.LoginInfo.Agent = agentID; | ||
98 | user.LoginInfo.Session = sessionID; | ||
99 | user.LoginInfo.First = ""; | ||
100 | user.LoginInfo.Last = ""; | ||
101 | |||
102 | } | ||
103 | else | ||
104 | { | ||
105 | // Invalid | ||
106 | user.Authorised = false; | ||
107 | } | ||
108 | |||
109 | return(user); | ||
110 | } | ||
111 | |||
112 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | ||
113 | { | ||
114 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + circuitCode.ToString() + "/delete"); | ||
115 | WebResponse GridResponse = DeleteSession.GetResponse(); | ||
116 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); | ||
117 | String grTest = sr.ReadLine(); | ||
118 | sr.Close(); | ||
119 | GridResponse.Close(); | ||
120 | ServerConsole.MainConsole.Instance.WriteLine("DEBUG: " + grTest); | ||
121 | return(true); | ||
122 | } | ||
123 | |||
124 | public UUIDBlock RequestUUIDBlock() | ||
125 | { | ||
126 | UUIDBlock uuidBlock = new UUIDBlock(); | ||
127 | return(uuidBlock); | ||
128 | } | ||
129 | |||
130 | public void RequestNeighbours() | ||
131 | { | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
136 | { | ||
137 | this.GridServerUrl = ServerUrl; | ||
138 | this.GridSendKey = ServerKey; | ||
139 | } | ||
140 | |||
141 | public void AddNewSession(Login session) | ||
142 | { | ||
143 | |||
144 | } | ||
145 | } | ||
146 | |||
147 | |||
148 | public class RemoteAssetServer : IAssetServer | ||
149 | { | ||
150 | private IAssetReceiver _receiver; | ||
151 | private BlockingQueue<ARequest> _assetRequests; | ||
152 | private Thread _remoteAssetServerThread; | ||
153 | private string AssetServerUrl; | ||
154 | private string AssetSendKey; | ||
155 | |||
156 | public RemoteAssetServer() | ||
157 | { | ||
158 | this._assetRequests = new BlockingQueue<ARequest>(); | ||
159 | this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); | ||
160 | this._remoteAssetServerThread.IsBackground = true; | ||
161 | this._remoteAssetServerThread.Start(); | ||
162 | ServerConsole.MainConsole.Instance.WriteLine("Remote Asset Server class created"); | ||
163 | } | ||
164 | |||
165 | public void SetReceiver(IAssetReceiver receiver) | ||
166 | { | ||
167 | this._receiver = receiver; | ||
168 | } | ||
169 | |||
170 | public void RequestAsset(LLUUID assetID, bool isTexture) | ||
171 | { | ||
172 | ARequest req = new ARequest(); | ||
173 | req.AssetID = assetID; | ||
174 | req.IsTexture = isTexture; | ||
175 | this._assetRequests.Enqueue(req); | ||
176 | } | ||
177 | |||
178 | public void UpdateAsset(AssetBase asset) | ||
179 | { | ||
180 | |||
181 | } | ||
182 | |||
183 | public void UploadNewAsset(AssetBase asset) | ||
184 | { | ||
185 | |||
186 | } | ||
187 | |||
188 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
189 | { | ||
190 | this.AssetServerUrl = ServerUrl; | ||
191 | this.AssetSendKey = ServerKey; | ||
192 | } | ||
193 | |||
194 | private void RunRequests() | ||
195 | { | ||
196 | while(true) | ||
197 | { | ||
198 | //we need to add support for the asset server not knowing about a requested asset | ||
199 | ARequest req = this._assetRequests.Dequeue(); | ||
200 | LLUUID assetID = req.AssetID; | ||
201 | ServerConsole.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it"); | ||
202 | WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data"); | ||
203 | WebResponse AssetResponse = AssetLoad.GetResponse(); | ||
204 | byte[] idata = new byte[(int)AssetResponse.ContentLength]; | ||
205 | BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); | ||
206 | idata = br.ReadBytes((int)AssetResponse.ContentLength); | ||
207 | br.Close(); | ||
208 | |||
209 | AssetBase asset = new AssetBase(); | ||
210 | asset.FullID = assetID; | ||
211 | asset.Data = idata; | ||
212 | _receiver.AssetReceived(asset, req.IsTexture ); | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | |||
217 | public class BlockingQueue< T > { | ||
218 | private Queue< T > _queue = new Queue< T >(); | ||
219 | private object _queueSync = new object(); | ||
220 | |||
221 | public void Enqueue(T value) | ||
222 | { | ||
223 | lock(_queueSync) | ||
224 | { | ||
225 | _queue.Enqueue(value); | ||
226 | Monitor.Pulse(_queueSync); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | public T Dequeue() | ||
231 | { | ||
232 | lock(_queueSync) | ||
233 | { | ||
234 | if( _queue.Count < 1) | ||
235 | Monitor.Wait(_queueSync); | ||
236 | |||
237 | return _queue.Dequeue(); | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | } | ||
diff --git a/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj new file mode 100644 index 0000000..6fc1e5a --- /dev/null +++ b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.csproj | |||
@@ -0,0 +1,49 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>RemoteGridServers</RootNamespace> | ||
5 | <AssemblyName>RemoteGridServers</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="libsecondlife"> | ||
30 | <HintPath>..\..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <Compile Include="RemoteGrid.cs" /> | ||
36 | <Compile Include="AssemblyInfo.cs" /> | ||
37 | </ItemGroup> | ||
38 | <ItemGroup> | ||
39 | <ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
40 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
41 | <Name>ServerConsole</Name> | ||
42 | </ProjectReference> | ||
43 | <ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj"> | ||
44 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
45 | <Name>GridInterfaces</Name> | ||
46 | </ProjectReference> | ||
47 | </ItemGroup> | ||
48 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
49 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.sln b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.sln new file mode 100644 index 0000000..a990022 --- /dev/null +++ b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGridServers.sln | |||
@@ -0,0 +1,7 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/RemoteServers/default.build b/ConvertToPlugins/src/RemoteServers/default.build new file mode 100644 index 0000000..8819600 --- /dev/null +++ b/ConvertToPlugins/src/RemoteServers/default.build | |||
@@ -0,0 +1,51 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../bin/RemoteGridServers.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="RemoteGridServers/AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-remoteservers" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="Connects to remote OGS installation" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/RemoteGridServers.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../bin" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | <include name="libsecondlife.dll" /> | ||
43 | <include name="GridInterfaces.dll" /> | ||
44 | <include name="ServerConsole.dll" /> | ||
45 | </references> | ||
46 | <sources basedir="RemoteGridServers/"> | ||
47 | <include name="*.cs" /> | ||
48 | </sources> | ||
49 | </csc> | ||
50 | </target> | ||
51 | </project> | ||
diff --git a/ConvertToPlugins/src/Second-server.csproj b/ConvertToPlugins/src/Second-server.csproj new file mode 100644 index 0000000..dfb5168 --- /dev/null +++ b/ConvertToPlugins/src/Second-server.csproj | |||
@@ -0,0 +1,92 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Exe</OutputType> | ||
4 | <RootNamespace>OpenSim</RootNamespace> | ||
5 | <AssemblyName>OpenSim</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid> | ||
9 | <StartupObject>OpenSim.OpenSim_Main</StartupObject> | ||
10 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
11 | <NoStdLib>False</NoStdLib> | ||
12 | <WarningLevel>4</WarningLevel> | ||
13 | <TreatWarningsAsErrors>false</TreatWarningsAsErrors> | ||
14 | </PropertyGroup> | ||
15 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
16 | <OutputPath>bin\</OutputPath> | ||
17 | <Optimize>False</Optimize> | ||
18 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
19 | <DebugSymbols>true</DebugSymbols> | ||
20 | <DebugType>Full</DebugType> | ||
21 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
22 | </PropertyGroup> | ||
23 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
24 | <OutputPath>..\bin\</OutputPath> | ||
25 | <Optimize>True</Optimize> | ||
26 | <DefineConstants>TRACE</DefineConstants> | ||
27 | <DebugSymbols>False</DebugSymbols> | ||
28 | <DebugType>None</DebugType> | ||
29 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
30 | </PropertyGroup> | ||
31 | <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> | ||
32 | <RegisterForComInterop>False</RegisterForComInterop> | ||
33 | <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> | ||
34 | <BaseAddress>4194304</BaseAddress> | ||
35 | <PlatformTarget>AnyCPU</PlatformTarget> | ||
36 | <FileAlignment>4096</FileAlignment> | ||
37 | </PropertyGroup> | ||
38 | <ItemGroup> | ||
39 | <Reference Include="System" /> | ||
40 | <Reference Include="System.Data" /> | ||
41 | <Reference Include="System.Xml" /> | ||
42 | <Reference Include="libsecondlife"> | ||
43 | <HintPath>..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
44 | <SpecificVersion>False</SpecificVersion> | ||
45 | </Reference> | ||
46 | <Reference Include="Axiom.MathLib"> | ||
47 | <HintPath>..\..\..\..\..\Opensim-pluginsystem\bin\Axiom.MathLib.dll</HintPath> | ||
48 | <SpecificVersion>False</SpecificVersion> | ||
49 | </Reference> | ||
50 | <Reference Include="log4net"> | ||
51 | <HintPath>..\bin\log4net.dll</HintPath> | ||
52 | <SpecificVersion>False</SpecificVersion> | ||
53 | </Reference> | ||
54 | </ItemGroup> | ||
55 | <ItemGroup> | ||
56 | <Compile Include="Config.cs" /> | ||
57 | <Compile Include="Main.cs" /> | ||
58 | <Compile Include="OpenSimClient.cs" /> | ||
59 | <Compile Include="types\Mesh.cs" /> | ||
60 | <Compile Include="types\Triangle.cs" /> | ||
61 | <Compile Include="Util.cs" /> | ||
62 | <Compile Include="world\Avatar.cs" /> | ||
63 | <Compile Include="world\Entity.cs" /> | ||
64 | <Compile Include="world\Primitive.cs" /> | ||
65 | <Compile Include="world\ScriptEngine.cs" /> | ||
66 | <Compile Include="world\scripting\IScript.cs" /> | ||
67 | <Compile Include="world\SurfacePatch.cs" /> | ||
68 | <Compile Include="world\World.cs" /> | ||
69 | <Compile Include="GridServers\LoginServer.cs" /> | ||
70 | <Compile Include="Assets\AssetCache.cs" /> | ||
71 | <Compile Include="OpenSimConsole.cs" /> | ||
72 | <Compile Include="HeightMapGenHills.cs" /> | ||
73 | <Compile Include="VersionInfo.cs" /> | ||
74 | </ItemGroup> | ||
75 | <ItemGroup> | ||
76 | <Folder Include="GridServers" /> | ||
77 | <Folder Include="Assets" /> | ||
78 | <ProjectReference Include="GridInterfaces\GridInterfaces.csproj"> | ||
79 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
80 | <Name>GridInterfaces</Name> | ||
81 | </ProjectReference> | ||
82 | <ProjectReference Include="physics\PhysicsManager.csproj"> | ||
83 | <Project>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</Project> | ||
84 | <Name>PhysicsManager</Name> | ||
85 | </ProjectReference> | ||
86 | <ProjectReference Include="ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
87 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
88 | <Name>ServerConsole</Name> | ||
89 | </ProjectReference> | ||
90 | </ItemGroup> | ||
91 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
92 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/Second-server.sln b/ConvertToPlugins/src/Second-server.sln new file mode 100644 index 0000000..96755ee --- /dev/null +++ b/ConvertToPlugins/src/Second-server.sln | |||
@@ -0,0 +1,96 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" | ||
5 | EndProject | ||
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "Config\SimConfig\SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}" | ||
7 | EndProject | ||
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalServers\LocalGridServers\LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}" | ||
9 | EndProject | ||
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteServers\RemoteGridServers\RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}" | ||
11 | EndProject | ||
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces\GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}" | ||
13 | EndProject | ||
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "physics\PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}" | ||
15 | EndProject | ||
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "physics\plugins\PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}" | ||
17 | EndProject | ||
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}" | ||
19 | EndProject | ||
20 | Global | ||
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
22 | Debug|.NET 1.1 = Debug|.NET 1.1 | ||
23 | Debug|Any CPU = Debug|Any CPU | ||
24 | Release|.NET 1.1 = Release|.NET 1.1 | ||
25 | Release|Any CPU = Release|Any CPU | ||
26 | EndGlobalSection | ||
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
28 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.ActiveCfg = Debug|Any CPU | ||
29 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|Any CPU | ||
30 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
31 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
32 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.ActiveCfg = Release|Any CPU | ||
33 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
34 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
35 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
36 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
37 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
38 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
39 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
40 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
41 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
42 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
43 | {B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
44 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
45 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
46 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
47 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
48 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
49 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
50 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
51 | {5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
52 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
53 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
54 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
55 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
56 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
57 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
58 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.Build.0 = Release|Any CPU | ||
59 | {D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
60 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
61 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
62 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
63 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
64 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
65 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
66 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
67 | {CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
68 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
69 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
70 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
71 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
72 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
73 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
74 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
75 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
76 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
77 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
78 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
79 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
80 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
81 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
82 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
83 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
84 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
85 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
86 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
87 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
88 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
89 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
90 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU | ||
91 | {C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
92 | EndGlobalSection | ||
93 | GlobalSection(SolutionProperties) = preSolution | ||
94 | HideSolutionNode = FALSE | ||
95 | EndGlobalSection | ||
96 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/ServerConsole/ServerConsole/AssemblyInfo.cs b/ConvertToPlugins/src/ServerConsole/ServerConsole/AssemblyInfo.cs new file mode 100644 index 0000000..00a9b7d --- /dev/null +++ b/ConvertToPlugins/src/ServerConsole/ServerConsole/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("ServerConsole")] | ||
12 | [assembly: AssemblyDescription("")] | ||
13 | [assembly: AssemblyConfiguration("")] | ||
14 | [assembly: AssemblyCompany("")] | ||
15 | [assembly: AssemblyProduct("ServerConsole")] | ||
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/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.cs b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.cs new file mode 100644 index 0000000..93c8114 --- /dev/null +++ b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.cs | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | |||
29 | namespace ServerConsole | ||
30 | { | ||
31 | public class MainConsole { | ||
32 | |||
33 | private static ConsoleBase instance; | ||
34 | |||
35 | public static ConsoleBase Instance | ||
36 | { | ||
37 | get | ||
38 | { | ||
39 | return instance; | ||
40 | } | ||
41 | set | ||
42 | { | ||
43 | instance = value; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | public MainConsole() | ||
48 | { | ||
49 | |||
50 | } | ||
51 | } | ||
52 | |||
53 | public abstract class ConsoleBase | ||
54 | { | ||
55 | |||
56 | public enum ConsoleType { | ||
57 | Local, // Use stdio | ||
58 | TCP, // Use TCP/telnet | ||
59 | SimChat // Use in-world chat (for gods) | ||
60 | } | ||
61 | |||
62 | public abstract void Close(); | ||
63 | |||
64 | // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here | ||
65 | public abstract void WriteLine(string Line) ; | ||
66 | |||
67 | public abstract string ReadLine(); | ||
68 | |||
69 | public abstract int Read() ; | ||
70 | |||
71 | public abstract void Write(string Line) ; | ||
72 | |||
73 | // Displays a command prompt and waits for the user to enter a string, then returns that string | ||
74 | public abstract string CmdPrompt(string prompt) ; | ||
75 | |||
76 | // Displays a command prompt and returns a default value if the user simply presses enter | ||
77 | public abstract string CmdPrompt(string prompt, string defaultresponse); | ||
78 | |||
79 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | ||
80 | public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ; | ||
81 | |||
82 | // Runs a command with a number of parameters | ||
83 | public abstract Object RunCmd(string Cmd, string[] cmdparams) ; | ||
84 | |||
85 | // Shows data about something | ||
86 | public abstract void ShowCommands(string ShowWhat) ; | ||
87 | |||
88 | // Displays a prompt to the user and then runs the command they entered | ||
89 | public abstract void MainConsolePrompt() ; | ||
90 | } | ||
91 | } | ||
diff --git a/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.csproj b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.csproj new file mode 100644 index 0000000..3d85860 --- /dev/null +++ b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.csproj | |||
@@ -0,0 +1,35 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>ServerConsole</RootNamespace> | ||
5 | <AssemblyName>ServerConsole</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | </ItemGroup> | ||
30 | <ItemGroup> | ||
31 | <Compile Include="ServerConsole.cs" /> | ||
32 | <Compile Include="AssemblyInfo.cs" /> | ||
33 | </ItemGroup> | ||
34 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
35 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.sln b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.sln new file mode 100644 index 0000000..07445db --- /dev/null +++ b/ConvertToPlugins/src/ServerConsole/ServerConsole/ServerConsole.sln | |||
@@ -0,0 +1,7 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/ServerConsole/default.build b/ConvertToPlugins/src/ServerConsole/default.build new file mode 100644 index 0000000..a6f6dc2 --- /dev/null +++ b/ConvertToPlugins/src/ServerConsole/default.build | |||
@@ -0,0 +1,48 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../bin/ServerConsole.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="ServerConsole/AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-serverconsole" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="The default server console" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/ServerConsole.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | </references> | ||
43 | <sources basedir="ServerConsole/"> | ||
44 | <include name="*.cs" /> | ||
45 | </sources> | ||
46 | </csc> | ||
47 | </target> | ||
48 | </project> | ||
diff --git a/ConvertToPlugins/src/Util.cs b/ConvertToPlugins/src/Util.cs new file mode 100644 index 0000000..d575bee --- /dev/null +++ b/ConvertToPlugins/src/Util.cs | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Threading; | ||
33 | using libsecondlife; | ||
34 | using libsecondlife.Packets; | ||
35 | |||
36 | namespace OpenSim | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// </summary> | ||
40 | /// | ||
41 | public class Util | ||
42 | { | ||
43 | public static ulong UIntsToLong(uint X, uint Y) | ||
44 | { | ||
45 | return Helpers.UIntsToLong(X,Y); | ||
46 | } | ||
47 | public Util() | ||
48 | { | ||
49 | |||
50 | } | ||
51 | } | ||
52 | |||
53 | public class QueItem { | ||
54 | public QueItem() | ||
55 | { | ||
56 | } | ||
57 | |||
58 | public Packet Packet; | ||
59 | public bool Incoming; | ||
60 | } | ||
61 | |||
62 | |||
63 | public class BlockingQueue< T > { | ||
64 | private Queue< T > _queue = new Queue< T >(); | ||
65 | private object _queueSync = new object(); | ||
66 | |||
67 | public void Enqueue(T value) | ||
68 | { | ||
69 | lock(_queueSync) | ||
70 | { | ||
71 | _queue.Enqueue(value); | ||
72 | Monitor.Pulse(_queueSync); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public T Dequeue() | ||
77 | { | ||
78 | lock(_queueSync) | ||
79 | { | ||
80 | if( _queue.Count < 1) | ||
81 | Monitor.Wait(_queueSync); | ||
82 | |||
83 | return _queue.Dequeue(); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | } | ||
diff --git a/ConvertToPlugins/src/VersionInfo.cs b/ConvertToPlugins/src/VersionInfo.cs new file mode 100644 index 0000000..949462c --- /dev/null +++ b/ConvertToPlugins/src/VersionInfo.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | Copyright (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 | |||
27 | using System; | ||
28 | |||
29 | namespace OpenSim | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// </summary> | ||
33 | public class VersionInfo | ||
34 | { | ||
35 | public static string Version = "0.1, Build 1173288035, Revision 148M"; | ||
36 | } | ||
37 | } | ||
diff --git a/ConvertToPlugins/src/VersionInfo.cs.template b/ConvertToPlugins/src/VersionInfo.cs.template new file mode 100644 index 0000000..e4e1b95 --- /dev/null +++ b/ConvertToPlugins/src/VersionInfo.cs.template | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | Copyright (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 | |||
27 | using System; | ||
28 | |||
29 | namespace OpenSim | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// </summary> | ||
33 | public class VersionInfo | ||
34 | { | ||
35 | public static string Version = "@@VERSION"; | ||
36 | } | ||
37 | } | ||
diff --git a/ConvertToPlugins/src/physics/AssemblyInfo.cs b/ConvertToPlugins/src/physics/AssemblyInfo.cs new file mode 100644 index 0000000..57a8913 --- /dev/null +++ b/ConvertToPlugins/src/physics/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("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/ConvertToPlugins/src/physics/PhysicsManager.cs b/ConvertToPlugins/src/physics/PhysicsManager.cs new file mode 100644 index 0000000..0986501 --- /dev/null +++ b/ConvertToPlugins/src/physics/PhysicsManager.cs | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | |||
33 | namespace PhysicsSystem | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Description of MyClass. | ||
37 | /// </summary> | ||
38 | public class PhysicsManager | ||
39 | { | ||
40 | private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>(); | ||
41 | |||
42 | public PhysicsManager() | ||
43 | { | ||
44 | |||
45 | } | ||
46 | |||
47 | public PhysicsScene GetPhysicsScene(string engineName) | ||
48 | { | ||
49 | if(_plugins.ContainsKey(engineName)) | ||
50 | { | ||
51 | ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName); | ||
52 | return _plugins[engineName].GetScene(); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | ServerConsole.MainConsole.Instance.WriteLine("couldn't find physicsEngine: "+ engineName); | ||
57 | return null; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | public void LoadPlugins() | ||
62 | { | ||
63 | string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics"); | ||
64 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); | ||
65 | |||
66 | |||
67 | for(int i= 0; i<pluginFiles.Length; i++) | ||
68 | { | ||
69 | this.AddPlugin(pluginFiles[i]); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | private void AddPlugin(string FileName) | ||
74 | { | ||
75 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
76 | |||
77 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
78 | { | ||
79 | if (pluginType.IsPublic) | ||
80 | { | ||
81 | if (!pluginType.IsAbstract) | ||
82 | { | ||
83 | Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); | ||
84 | |||
85 | if (typeInterface != null) | ||
86 | { | ||
87 | IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
88 | plug.Init(); | ||
89 | this._plugins.Add(plug.GetName(),plug); | ||
90 | |||
91 | } | ||
92 | |||
93 | typeInterface = null; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | pluginAssembly = null; | ||
99 | } | ||
100 | } | ||
101 | public interface IPhysicsPlugin | ||
102 | { | ||
103 | bool Init(); | ||
104 | PhysicsScene GetScene(); | ||
105 | string GetName(); | ||
106 | void Dispose(); | ||
107 | } | ||
108 | |||
109 | public abstract class PhysicsScene | ||
110 | { | ||
111 | public abstract PhysicsActor AddAvatar(PhysicsVector position); | ||
112 | |||
113 | public abstract void Simulate(float timeStep); | ||
114 | |||
115 | public abstract void GetResults(); | ||
116 | |||
117 | public abstract void SetTerrain(float[] heightMap); | ||
118 | |||
119 | public abstract bool IsThreaded | ||
120 | { | ||
121 | get; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public abstract class PhysicsActor | ||
126 | { | ||
127 | public abstract PhysicsVector Position | ||
128 | { | ||
129 | get; | ||
130 | set; | ||
131 | } | ||
132 | |||
133 | public abstract PhysicsVector Velocity | ||
134 | { | ||
135 | get; | ||
136 | set; | ||
137 | } | ||
138 | |||
139 | public abstract PhysicsVector Acceleration | ||
140 | { | ||
141 | get; | ||
142 | } | ||
143 | |||
144 | public abstract void AddForce(PhysicsVector force); | ||
145 | |||
146 | public abstract void SetMomentum(PhysicsVector momentum); | ||
147 | } | ||
148 | |||
149 | public class PhysicsVector | ||
150 | { | ||
151 | public float X; | ||
152 | public float Y; | ||
153 | public float Z; | ||
154 | |||
155 | public PhysicsVector() | ||
156 | { | ||
157 | |||
158 | } | ||
159 | |||
160 | public PhysicsVector(float x, float y, float z) | ||
161 | { | ||
162 | X = x; | ||
163 | Y = y; | ||
164 | Z = z; | ||
165 | } | ||
166 | } | ||
167 | } | ||
diff --git a/ConvertToPlugins/src/physics/PhysicsManager.csproj b/ConvertToPlugins/src/physics/PhysicsManager.csproj new file mode 100644 index 0000000..dc705e2 --- /dev/null +++ b/ConvertToPlugins/src/physics/PhysicsManager.csproj | |||
@@ -0,0 +1,41 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>PhysicsManager</RootNamespace> | ||
5 | <AssemblyName>PhysicsManager</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | </ItemGroup> | ||
30 | <ItemGroup> | ||
31 | <Compile Include="PhysicsManager.cs" /> | ||
32 | <Compile Include="AssemblyInfo.cs" /> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <ProjectReference Include="..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
36 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
37 | <Name>ServerConsole</Name> | ||
38 | </ProjectReference> | ||
39 | </ItemGroup> | ||
40 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
41 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/physics/PhysicsManager.sln b/ConvertToPlugins/src/physics/PhysicsManager.sln new file mode 100644 index 0000000..565813f --- /dev/null +++ b/ConvertToPlugins/src/physics/PhysicsManager.sln | |||
@@ -0,0 +1,23 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}" | ||
5 | EndProject | ||
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "..\PhysXplugin\PhysXplugin\PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}" | ||
7 | EndProject | ||
8 | Global | ||
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
10 | Debug|Any CPU = Debug|Any CPU | ||
11 | Release|Any CPU = Release|Any CPU | ||
12 | EndGlobalSection | ||
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
14 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
15 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
16 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
17 | {3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
18 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
19 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
20 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
21 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
22 | EndGlobalSection | ||
23 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/physics/default.build b/ConvertToPlugins/src/physics/default.build new file mode 100644 index 0000000..d39e62b --- /dev/null +++ b/ConvertToPlugins/src/physics/default.build | |||
@@ -0,0 +1,49 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../bin/PhysicsManager.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../VERSION" property="svnver"/> | ||
22 | <asminfo output="AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-physicsmanager" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="Handles physics plugins" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../bin/PhysicsManager.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../bin" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | <include name="ServerConsole.dll" /> | ||
43 | </references> | ||
44 | <sources basedir="./"> | ||
45 | <include name="*.cs" /> | ||
46 | </sources> | ||
47 | </csc> | ||
48 | </target> | ||
49 | </project> | ||
diff --git a/ConvertToPlugins/src/physics/plugins/AssemblyInfo.cs b/ConvertToPlugins/src/physics/plugins/AssemblyInfo.cs new file mode 100644 index 0000000..0c9c06c --- /dev/null +++ b/ConvertToPlugins/src/physics/plugins/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("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/ConvertToPlugins/src/physics/plugins/PhysXplugin.cs b/ConvertToPlugins/src/physics/plugins/PhysXplugin.cs new file mode 100644 index 0000000..58a82fb --- /dev/null +++ b/ConvertToPlugins/src/physics/plugins/PhysXplugin.cs | |||
@@ -0,0 +1,199 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using PhysicsSystem; | ||
30 | |||
31 | namespace PhysXplugin | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Will be the PhysX plugin but for now will be a very basic physics engine | ||
35 | /// </summary> | ||
36 | public class PhysXPlugin : IPhysicsPlugin | ||
37 | { | ||
38 | private PhysXScene _mScene; | ||
39 | |||
40 | public PhysXPlugin() | ||
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 PhysXScene(); | ||
55 | } | ||
56 | return(_mScene); | ||
57 | } | ||
58 | |||
59 | public string GetName() | ||
60 | { | ||
61 | return("PhysX"); | ||
62 | } | ||
63 | |||
64 | public void Dispose() | ||
65 | { | ||
66 | |||
67 | } | ||
68 | } | ||
69 | |||
70 | public class PhysXScene :PhysicsScene | ||
71 | { | ||
72 | private List<PhysXActor> _actors = new List<PhysXActor>(); | ||
73 | private float[] _heightMap; | ||
74 | |||
75 | public PhysXScene() | ||
76 | { | ||
77 | |||
78 | } | ||
79 | |||
80 | public override PhysicsActor AddAvatar(PhysicsVector position) | ||
81 | { | ||
82 | PhysXActor act = new PhysXActor(); | ||
83 | act.Position = position; | ||
84 | _actors.Add(act); | ||
85 | return act; | ||
86 | } | ||
87 | |||
88 | public override void Simulate(float timeStep) | ||
89 | { | ||
90 | foreach (PhysXActor actor in _actors) | ||
91 | { | ||
92 | actor.Position.X = actor.Position.X + actor.Velocity.X * timeStep; | ||
93 | actor.Position.Y = actor.Position.Y + actor.Velocity.Y * timeStep; | ||
94 | actor.Position.Z = actor.Position.Z + actor.Velocity.Z * timeStep; | ||
95 | actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1; | ||
96 | if(actor.Position.X<0) | ||
97 | { | ||
98 | actor.Position.X = 0; | ||
99 | actor.Velocity.X = 0; | ||
100 | } | ||
101 | if(actor.Position.Y < 0) | ||
102 | { | ||
103 | actor.Position.Y = 0; | ||
104 | actor.Velocity.Y = 0; | ||
105 | } | ||
106 | if(actor.Position.X > 255) | ||
107 | { | ||
108 | actor.Position.X = 255; | ||
109 | actor.Velocity.X = 0; | ||
110 | } | ||
111 | if(actor.Position.Y > 255) | ||
112 | { | ||
113 | actor.Position.Y = 255; | ||
114 | actor.Velocity.X = 0; | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | public override void GetResults() | ||
120 | { | ||
121 | |||
122 | } | ||
123 | |||
124 | public override bool IsThreaded | ||
125 | { | ||
126 | get | ||
127 | { | ||
128 | return(false); // for now we won't be multithreaded | ||
129 | } | ||
130 | } | ||
131 | |||
132 | public override void SetTerrain(float[] heightMap) | ||
133 | { | ||
134 | this._heightMap = heightMap; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public class PhysXActor : PhysicsActor | ||
139 | { | ||
140 | private PhysicsVector _position; | ||
141 | private PhysicsVector _velocity; | ||
142 | private PhysicsVector _acceleration; | ||
143 | |||
144 | public PhysXActor() | ||
145 | { | ||
146 | _velocity = new PhysicsVector(); | ||
147 | _position = new PhysicsVector(); | ||
148 | _acceleration = new PhysicsVector(); | ||
149 | } | ||
150 | |||
151 | public override PhysicsVector Position | ||
152 | { | ||
153 | get | ||
154 | { | ||
155 | return _position; | ||
156 | } | ||
157 | set | ||
158 | { | ||
159 | _position = value; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | public override PhysicsVector Velocity | ||
164 | { | ||
165 | get | ||
166 | { | ||
167 | return _velocity; | ||
168 | } | ||
169 | set | ||
170 | { | ||
171 | _velocity = value; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | public override PhysicsVector Acceleration | ||
176 | { | ||
177 | get | ||
178 | { | ||
179 | return _acceleration; | ||
180 | } | ||
181 | |||
182 | } | ||
183 | public void SetAcceleration (PhysicsVector accel) | ||
184 | { | ||
185 | this._acceleration = accel; | ||
186 | } | ||
187 | |||
188 | public override void AddForce(PhysicsVector force) | ||
189 | { | ||
190 | |||
191 | } | ||
192 | |||
193 | public override void SetMomentum(PhysicsVector momentum) | ||
194 | { | ||
195 | |||
196 | } | ||
197 | } | ||
198 | |||
199 | } | ||
diff --git a/ConvertToPlugins/src/physics/plugins/PhysXplugin.csproj b/ConvertToPlugins/src/physics/plugins/PhysXplugin.csproj new file mode 100644 index 0000000..1b84046 --- /dev/null +++ b/ConvertToPlugins/src/physics/plugins/PhysXplugin.csproj | |||
@@ -0,0 +1,41 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>PhysXplugin</RootNamespace> | ||
5 | <AssemblyName>PhysXplugin</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{ADB751AA-8426-4668-B1FA-43762126CEB3}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | </ItemGroup> | ||
30 | <ItemGroup> | ||
31 | <Compile Include="PhysXplugin.cs" /> | ||
32 | <Compile Include="AssemblyInfo.cs" /> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <ProjectReference Include="..\PhysicsManager.csproj"> | ||
36 | <Project>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</Project> | ||
37 | <Name>PhysicsManager</Name> | ||
38 | </ProjectReference> | ||
39 | </ItemGroup> | ||
40 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
41 | </Project> \ No newline at end of file | ||
diff --git a/ConvertToPlugins/src/physics/plugins/PhysXplugin.sln b/ConvertToPlugins/src/physics/plugins/PhysXplugin.sln new file mode 100644 index 0000000..06e73d1 --- /dev/null +++ b/ConvertToPlugins/src/physics/plugins/PhysXplugin.sln | |||
@@ -0,0 +1,17 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}" | ||
5 | EndProject | ||
6 | Global | ||
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
8 | Debug|Any CPU = Debug|Any CPU | ||
9 | Release|Any CPU = Release|Any CPU | ||
10 | EndGlobalSection | ||
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
12 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
13 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
14 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
15 | {ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
16 | EndGlobalSection | ||
17 | EndGlobal | ||
diff --git a/ConvertToPlugins/src/physics/plugins/default.build b/ConvertToPlugins/src/physics/plugins/default.build new file mode 100644 index 0000000..c40fea1 --- /dev/null +++ b/ConvertToPlugins/src/physics/plugins/default.build | |||
@@ -0,0 +1,49 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <project name="OpenSim" default="build" basedir="."> | ||
3 | <description>nant buildfile for OpenSim</description> | ||
4 | <property name="debug" value="true" overwrite="false" /> | ||
5 | <target name="clean" description="remove all generated files"> | ||
6 | <delete file="../../../bin/Physics/PhysXplugin.dll" failonerror="false" /> | ||
7 | </target> | ||
8 | |||
9 | <target name="svnupdate" description="updates to latest SVN"> | ||
10 | <exec program="svn"> | ||
11 | <arg value="update" /> | ||
12 | </exec> | ||
13 | </target> | ||
14 | |||
15 | <target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build"> | ||
16 | |||
17 | </target> | ||
18 | |||
19 | <target name="build" description="compiles the source code"> | ||
20 | |||
21 | <loadfile file="../../../VERSION" property="svnver"/> | ||
22 | <asminfo output="AssemblyInfo.cs" language="CSharp"> | ||
23 | <imports> | ||
24 | <import namespace="System" /> | ||
25 | <import namespace="System.Reflection" /> | ||
26 | <import namespace="System.Runtime.InteropServices" /> | ||
27 | </imports> | ||
28 | <attributes> | ||
29 | <attribute type="ComVisibleAttribute" value="false" /> | ||
30 | <attribute type="CLSCompliantAttribute" value="false" /> | ||
31 | <attribute type="AssemblyVersionAttribute" value="${svnver}" /> | ||
32 | <attribute type="AssemblyTitleAttribute" value="opensim-physicsmanager-physx" /> | ||
33 | <attribute type="AssemblyDescriptionAttribute" value="PhysX plugin for OpenSim" /> | ||
34 | <attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/> | ||
35 | </attributes> | ||
36 | </asminfo> | ||
37 | |||
38 | <csc target="library" output="../../../bin/Physics/PhysXplugin.dll" debug="${debug}" verbose="true" warninglevel="4"> | ||
39 | <references basedir="../../../bin" failonempty="true"> | ||
40 | <include name="System" /> | ||
41 | <include name="System.Xml" /> | ||
42 | <include name="PhysicsManager.dll" /> | ||
43 | </references> | ||
44 | <sources basedir="./"> | ||
45 | <include name="*.cs" /> | ||
46 | </sources> | ||
47 | </csc> | ||
48 | </target> | ||
49 | </project> | ||
diff --git a/ConvertToPlugins/src/types/Mesh.cs b/ConvertToPlugins/src/types/Mesh.cs new file mode 100644 index 0000000..3e00c91 --- /dev/null +++ b/ConvertToPlugins/src/types/Mesh.cs | |||
@@ -0,0 +1,28 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace 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/ConvertToPlugins/src/types/Triangle.cs b/ConvertToPlugins/src/types/Triangle.cs new file mode 100644 index 0000000..8dfea6e --- /dev/null +++ b/ConvertToPlugins/src/types/Triangle.cs | |||
@@ -0,0 +1,28 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | |||
6 | namespace 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/ConvertToPlugins/src/world/Avatar.cs b/ConvertToPlugins/src/world/Avatar.cs new file mode 100644 index 0000000..c8469f8 --- /dev/null +++ b/ConvertToPlugins/src/world/Avatar.cs | |||
@@ -0,0 +1,355 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | using PhysicsSystem; | ||
8 | using Axiom.MathLib; | ||
9 | |||
10 | namespace OpenSim.world | ||
11 | { | ||
12 | public class Avatar : Entity | ||
13 | { | ||
14 | public string firstname; | ||
15 | public string lastname; | ||
16 | public OpenSimClient ControllingClient; | ||
17 | private PhysicsActor _physActor; | ||
18 | private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
19 | private bool updateflag; | ||
20 | private bool walking; | ||
21 | private List<NewForce> forcesList = new List<NewForce>(); | ||
22 | private short _updateCount; | ||
23 | |||
24 | public Avatar(OpenSimClient TheClient) { | ||
25 | ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); | ||
26 | ControllingClient=TheClient; | ||
27 | SetupTemplate("avatar-template.dat"); | ||
28 | position = new LLVector3(100.0f,100.0f,30.0f); | ||
29 | position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1; | ||
30 | } | ||
31 | |||
32 | public PhysicsActor PhysActor | ||
33 | { | ||
34 | set | ||
35 | { | ||
36 | this._physActor = value; | ||
37 | } | ||
38 | } | ||
39 | public override void addForces() | ||
40 | { | ||
41 | lock(this.forcesList) | ||
42 | { | ||
43 | if(this.forcesList.Count>0) | ||
44 | { | ||
45 | for(int i=0 ; i < this.forcesList.Count; i++) | ||
46 | { | ||
47 | NewForce force = this.forcesList[i]; | ||
48 | PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); | ||
49 | this._physActor.Velocity = phyVector; | ||
50 | this.updateflag = true; | ||
51 | this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this | ||
52 | // but as we are setting the velocity (rather than using real forces) at the moment it is okay. | ||
53 | } | ||
54 | for(int i=0 ; i < this.forcesList.Count; i++) | ||
55 | { | ||
56 | this.forcesList.RemoveAt(0); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | public override void update() | ||
63 | { | ||
64 | |||
65 | if(this.updateflag) | ||
66 | { | ||
67 | //need to send movement info | ||
68 | //so create the improvedterseobjectupdate packet | ||
69 | //use CreateTerseBlock() | ||
70 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
71 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
72 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME | ||
73 | terse.RegionData.TimeDilation = 64096; | ||
74 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
75 | terse.ObjectData[0] = terseBlock; | ||
76 | foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { | ||
77 | client.OutPacket(terse); | ||
78 | } | ||
79 | |||
80 | updateflag =false; | ||
81 | this._updateCount = 0; | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | if(walking) | ||
86 | { | ||
87 | _updateCount++; | ||
88 | if(_updateCount>3) | ||
89 | { | ||
90 | //It has been a while since last update was sent so lets send one. | ||
91 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
92 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
93 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME | ||
94 | terse.RegionData.TimeDilation = 64096; | ||
95 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
96 | terse.ObjectData[0] = terseBlock; | ||
97 | foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { | ||
98 | client.OutPacket(terse); | ||
99 | } | ||
100 | _updateCount = 0; | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | |||
106 | private void SetupTemplate(string name) | ||
107 | { | ||
108 | |||
109 | int i = 0; | ||
110 | FileInfo fInfo = new FileInfo(name); | ||
111 | long numBytes = fInfo.Length; | ||
112 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
113 | BinaryReader br = new BinaryReader(fStream); | ||
114 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
115 | br.Close(); | ||
116 | fStream.Close(); | ||
117 | |||
118 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
119 | |||
120 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
121 | libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
122 | pos.X = 100f; | ||
123 | objdata.ID = 8880000; | ||
124 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
125 | libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); | ||
126 | //objdata.FullID=user.AgentID; | ||
127 | byte[] pb = pos.GetBytes(); | ||
128 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
129 | |||
130 | AvatarTemplate = objdata; | ||
131 | |||
132 | } | ||
133 | |||
134 | public void CompleteMovement(World RegionInfo) { | ||
135 | ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); | ||
136 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
137 | mov.AgentData.SessionID = this.ControllingClient.SessionID; | ||
138 | mov.AgentData.AgentID = this.ControllingClient.AgentID; | ||
139 | mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
140 | // TODO - dynamicalise this stuff | ||
141 | mov.Data.Timestamp = 1172750370; | ||
142 | mov.Data.Position = new LLVector3(100f, 100f, 23f); | ||
143 | mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); | ||
144 | |||
145 | ControllingClient.OutPacket(mov); | ||
146 | } | ||
147 | |||
148 | public void SendInitialPosition() { | ||
149 | |||
150 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
151 | //send a objectupdate packet with information about the clients avatar | ||
152 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
153 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
154 | objupdate.RegionData.TimeDilation = 64096; | ||
155 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
156 | |||
157 | objupdate.ObjectData[0] = AvatarTemplate; | ||
158 | //give this avatar object a local id and assign the user a name | ||
159 | objupdate.ObjectData[0].ID = this.localid; | ||
160 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
161 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
162 | |||
163 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
164 | |||
165 | byte[] pb = pos2.GetBytes(); | ||
166 | |||
167 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
168 | OpenSim_Main.local_world._localNumber++; | ||
169 | this.ControllingClient.OutPacket(objupdate); | ||
170 | } | ||
171 | |||
172 | public void SendInitialAppearance() { | ||
173 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
174 | aw.AgentData.AgentID = this.ControllingClient.AgentID; | ||
175 | aw.AgentData.SerialNum = 0; | ||
176 | aw.AgentData.SessionID = ControllingClient.SessionID; | ||
177 | |||
178 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
179 | AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
180 | awb.WearableType = (byte)0; | ||
181 | awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
182 | awb.ItemID = LLUUID.Random(); | ||
183 | aw.WearableData[0] = awb; | ||
184 | |||
185 | for(int i=1; i<13; i++) { | ||
186 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
187 | awb.WearableType = (byte)i; | ||
188 | awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
189 | awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
190 | aw.WearableData[i] = awb; | ||
191 | } | ||
192 | |||
193 | ControllingClient.OutPacket(aw); | ||
194 | } | ||
195 | |||
196 | public void HandleUpdate(AgentUpdatePacket pack) { | ||
197 | if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) { | ||
198 | if(!walking) | ||
199 | { | ||
200 | //we should add a new force to the list | ||
201 | // but for now we will deal with velocities | ||
202 | NewForce newVelocity = new NewForce(); | ||
203 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); | ||
204 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z); | ||
205 | Axiom.MathLib.Vector3 direc = q * v3; | ||
206 | direc.Normalize(); | ||
207 | |||
208 | //work out velocity for sim physics system | ||
209 | direc = direc * ((0.03f) * 128f); | ||
210 | newVelocity.X = direc.x; | ||
211 | newVelocity.Y = direc.y; | ||
212 | newVelocity.Z = direc.z; | ||
213 | this.forcesList.Add(newVelocity); | ||
214 | walking=true; | ||
215 | } | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | if(walking) | ||
220 | { | ||
221 | NewForce newVelocity = new NewForce(); | ||
222 | newVelocity.X = 0; | ||
223 | newVelocity.Y = 0; | ||
224 | newVelocity.Z = 0; | ||
225 | this.forcesList.Add(newVelocity); | ||
226 | walking = false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | //should be moved somewhere else | ||
232 | public void SendRegionHandshake(World RegionInfo) { | ||
233 | ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); | ||
234 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
235 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | ||
236 | |||
237 | ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); | ||
238 | handshake.RegionInfo.BillableFactor = 0; | ||
239 | handshake.RegionInfo.IsEstateManager = false; | ||
240 | handshake.RegionInfo.TerrainHeightRange00 = 60; | ||
241 | handshake.RegionInfo.TerrainHeightRange01 = 60; | ||
242 | handshake.RegionInfo.TerrainHeightRange10 = 60; | ||
243 | handshake.RegionInfo.TerrainHeightRange11 = 60; | ||
244 | handshake.RegionInfo.TerrainStartHeight00 = 10; | ||
245 | handshake.RegionInfo.TerrainStartHeight01 = 10; | ||
246 | handshake.RegionInfo.TerrainStartHeight10 = 10; | ||
247 | handshake.RegionInfo.TerrainStartHeight11 = 10; | ||
248 | handshake.RegionInfo.SimAccess = 13; | ||
249 | handshake.RegionInfo.WaterHeight = 5; | ||
250 | handshake.RegionInfo.RegionFlags = 72458694; | ||
251 | handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); | ||
252 | handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
253 | handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | ||
254 | handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | ||
255 | handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | ||
256 | handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | ||
257 | handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
258 | handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
259 | handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
260 | handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
261 | handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); | ||
262 | |||
263 | ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); | ||
264 | this.ControllingClient.OutPacket(handshake); | ||
265 | } | ||
266 | |||
267 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() | ||
268 | { | ||
269 | byte[] bytes = new byte[60]; | ||
270 | int i=0; | ||
271 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
272 | |||
273 | dat.TextureEntry = AvatarTemplate.TextureEntry; | ||
274 | libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); | ||
275 | |||
276 | uint ID = this.localid; | ||
277 | |||
278 | bytes[i++] = (byte)(ID % 256); | ||
279 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
280 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
281 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
282 | bytes[i++] = 0; | ||
283 | bytes[i++] = 1; | ||
284 | i += 14; | ||
285 | bytes[i++] = 128; | ||
286 | bytes[i++] = 63; | ||
287 | |||
288 | byte[] pb = pos2.GetBytes(); | ||
289 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
290 | i += 12; | ||
291 | ushort InternVelocityX; | ||
292 | ushort InternVelocityY; | ||
293 | ushort InternVelocityZ; | ||
294 | |||
295 | Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); | ||
296 | internDirec = internDirec /128.0f; | ||
297 | internDirec.x += 1; | ||
298 | internDirec.y += 1; | ||
299 | internDirec.z += 1; | ||
300 | |||
301 | InternVelocityX = (ushort)(32768 * internDirec.x); | ||
302 | InternVelocityY = (ushort)(32768 * internDirec.y); | ||
303 | InternVelocityZ = (ushort)(32768 * internDirec.z); | ||
304 | |||
305 | ushort ac = 32767; | ||
306 | bytes[i++] = (byte)(InternVelocityX % 256); | ||
307 | bytes[i++] = (byte)((InternVelocityX >> 8) % 256); | ||
308 | bytes[i++] = (byte)(InternVelocityY % 256); | ||
309 | bytes[i++] = (byte)((InternVelocityY>> 8) % 256); | ||
310 | bytes[i++] = (byte)(InternVelocityZ % 256); | ||
311 | bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); | ||
312 | |||
313 | //accel | ||
314 | bytes[i++] = (byte)(ac % 256); | ||
315 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
316 | bytes[i++] = (byte)(ac % 256); | ||
317 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
318 | bytes[i++] = (byte)(ac % 256); | ||
319 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
320 | |||
321 | //rot | ||
322 | bytes[i++] = (byte)(ac % 256); | ||
323 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
324 | bytes[i++] = (byte)(ac % 256); | ||
325 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
326 | bytes[i++] = (byte)(ac % 256); | ||
327 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
328 | bytes[i++] = (byte)(ac % 256); | ||
329 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
330 | |||
331 | //rotation vel | ||
332 | bytes[i++] = (byte)(ac % 256); | ||
333 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
334 | bytes[i++] = (byte)(ac % 256); | ||
335 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
336 | bytes[i++] = (byte)(ac % 256); | ||
337 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
338 | |||
339 | dat.Data=bytes; | ||
340 | return(dat); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | public class NewForce | ||
345 | { | ||
346 | public float X; | ||
347 | public float Y; | ||
348 | public float Z; | ||
349 | |||
350 | public NewForce() | ||
351 | { | ||
352 | |||
353 | } | ||
354 | } | ||
355 | } | ||
diff --git a/ConvertToPlugins/src/world/Entity.cs b/ConvertToPlugins/src/world/Entity.cs new file mode 100644 index 0000000..147478b --- /dev/null +++ b/ConvertToPlugins/src/world/Entity.cs | |||
@@ -0,0 +1,62 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | using OpenSim.types; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class Entity | ||
11 | { | ||
12 | public libsecondlife.LLUUID uuid; | ||
13 | public uint localid; | ||
14 | public LLVector3 position; | ||
15 | public LLVector3 velocity; | ||
16 | public Quaternion rotation; | ||
17 | protected string name; | ||
18 | protected List<Entity> children; | ||
19 | |||
20 | public Entity() | ||
21 | { | ||
22 | uuid = new libsecondlife.LLUUID(); | ||
23 | localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! | ||
24 | position = new LLVector3(); | ||
25 | velocity = new LLVector3(); | ||
26 | rotation = new Quaternion(); | ||
27 | name = "(basic entity)"; | ||
28 | children = new List<Entity>(); | ||
29 | } | ||
30 | public virtual void addForces() | ||
31 | { | ||
32 | foreach (Entity child in children) | ||
33 | { | ||
34 | child.addForces(); | ||
35 | } | ||
36 | } | ||
37 | public virtual void update() { | ||
38 | // Do any per-frame updates needed that are applicable to every type of entity | ||
39 | foreach (Entity child in children) | ||
40 | { | ||
41 | child.update(); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | public virtual string getName() | ||
46 | { | ||
47 | return name; | ||
48 | } | ||
49 | |||
50 | public virtual Mesh getMesh() | ||
51 | { | ||
52 | Mesh mesh = new Mesh(); | ||
53 | |||
54 | foreach (Entity child in children) | ||
55 | { | ||
56 | mesh += child.getMesh(); | ||
57 | } | ||
58 | |||
59 | return mesh; | ||
60 | } | ||
61 | } | ||
62 | } | ||
diff --git a/ConvertToPlugins/src/world/Primitive.cs b/ConvertToPlugins/src/world/Primitive.cs new file mode 100644 index 0000000..18b5715 --- /dev/null +++ b/ConvertToPlugins/src/world/Primitive.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.types; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class Primitive : Entity | ||
11 | { | ||
12 | protected float mesh_cutbegin; | ||
13 | protected float mesh_cutend; | ||
14 | protected PrimData primData; | ||
15 | protected bool newPrimFlag; | ||
16 | protected ObjectUpdatePacket OurPacket; | ||
17 | |||
18 | public Primitive() | ||
19 | { | ||
20 | mesh_cutbegin = 0.0f; | ||
21 | mesh_cutend = 1.0f; | ||
22 | } | ||
23 | |||
24 | public override Mesh getMesh() | ||
25 | { | ||
26 | Mesh mesh = new Mesh(); | ||
27 | Triangle tri = new Triangle( | ||
28 | new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), | ||
29 | new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), | ||
30 | new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); | ||
31 | |||
32 | mesh.AddTri(tri); | ||
33 | mesh += base.getMesh(); | ||
34 | |||
35 | return mesh; | ||
36 | } | ||
37 | |||
38 | public override void update() | ||
39 | { | ||
40 | if(this.newPrimFlag) | ||
41 | { | ||
42 | foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { | ||
43 | client.OutPacket(OurPacket); | ||
44 | } | ||
45 | this.newPrimFlag = false; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) | ||
50 | { | ||
51 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
52 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
53 | objupdate.RegionData.TimeDilation = 64096; | ||
54 | |||
55 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
56 | PrimData PData = new PrimData(); | ||
57 | this.primData = PData; | ||
58 | objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();//OpenSim_Main.local_world.PrimTemplate; | ||
59 | objupdate.ObjectData[0].PSBlock = new byte[0]; | ||
60 | objupdate.ObjectData[0].ExtraParams = new byte[1]; | ||
61 | objupdate.ObjectData[0].MediaURL = new byte[0]; | ||
62 | objupdate.ObjectData[0].NameValue = new byte[0]; | ||
63 | objupdate.ObjectData[0].PSBlock = new byte[0]; | ||
64 | objupdate.ObjectData[0].Text = new byte[0]; | ||
65 | objupdate.ObjectData[0].TextColor = new byte[4]; | ||
66 | objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); | ||
67 | objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0); | ||
68 | objupdate.ObjectData[0].Material = 3; | ||
69 | objupdate.ObjectData[0].TextureAnim = new byte[0]; | ||
70 | objupdate.ObjectData[0].Sound = LLUUID.Zero; | ||
71 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
72 | objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); | ||
73 | objupdate.ObjectData[0].State = 0; | ||
74 | objupdate.ObjectData[0].Data = new byte[0]; | ||
75 | PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; | ||
76 | PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; | ||
77 | PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; | ||
78 | PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; | ||
79 | PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; | ||
80 | PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; | ||
81 | PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; | ||
82 | PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; | ||
83 | PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; | ||
84 | PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
85 | PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
86 | PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; | ||
87 | PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; | ||
88 | PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
89 | PData.ParentID = objupdate.ObjectData[0].ParentID = 0; | ||
90 | PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
91 | //finish off copying rest of shape data | ||
92 | |||
93 | objupdate.ObjectData[0].ID = (uint)(localID); | ||
94 | objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda" + (localID- 702000).ToString("000")); | ||
95 | |||
96 | objupdate.ObjectData[0].ObjectData = new byte[60]; | ||
97 | objupdate.ObjectData[0].ObjectData[46] = 128; | ||
98 | objupdate.ObjectData[0].ObjectData[47] = 63; | ||
99 | LLVector3 pos1= addPacket.ObjectData.RayEnd; | ||
100 | //update position | ||
101 | byte[] pb = pos1.GetBytes(); | ||
102 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); | ||
103 | |||
104 | this.newPrimFlag = true; | ||
105 | this.uuid = objupdate.ObjectData[0].FullID; | ||
106 | this.localid = objupdate.ObjectData[0].ID; | ||
107 | this.position = pos1; | ||
108 | this.OurPacket = objupdate; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | public class PrimData | ||
113 | { | ||
114 | public LLUUID OwnerID; | ||
115 | public byte PCode; | ||
116 | public byte PathBegin; | ||
117 | public byte PathEnd; | ||
118 | public byte PathScaleX; | ||
119 | public byte PathScaleY; | ||
120 | public byte PathShearX; | ||
121 | public byte PathShearY; | ||
122 | public sbyte PathSkew; | ||
123 | public byte ProfileBegin; | ||
124 | public byte ProfileEnd; | ||
125 | public LLVector3 Scale; | ||
126 | public byte PathCurve; | ||
127 | public byte ProfileCurve; | ||
128 | public uint ParentID=0; | ||
129 | public byte ProfileHollow; | ||
130 | |||
131 | public PrimData() | ||
132 | { | ||
133 | |||
134 | } | ||
135 | } | ||
136 | } | ||
diff --git a/ConvertToPlugins/src/world/ScriptEngine.cs b/ConvertToPlugins/src/world/ScriptEngine.cs new file mode 100644 index 0000000..f20a08e --- /dev/null +++ b/ConvertToPlugins/src/world/ScriptEngine.cs | |||
@@ -0,0 +1,18 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world | ||
6 | { | ||
7 | public class ScriptEngine | ||
8 | { | ||
9 | public ScriptEngine(World env) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | public void LoadScript() | ||
14 | { | ||
15 | |||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/ConvertToPlugins/src/world/SurfacePatch.cs b/ConvertToPlugins/src/world/SurfacePatch.cs new file mode 100644 index 0000000..71e4116 --- /dev/null +++ b/ConvertToPlugins/src/world/SurfacePatch.cs | |||
@@ -0,0 +1,22 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world | ||
6 | { | ||
7 | public class SurfacePatch | ||
8 | { | ||
9 | public float[] HeightMap; | ||
10 | |||
11 | public SurfacePatch() { | ||
12 | HeightMap = new float[16*16]; | ||
13 | |||
14 | int xinc; | ||
15 | int yinc; | ||
16 | for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) { | ||
17 | HeightMap[xinc+(yinc*16)]=100.0f; | ||
18 | } | ||
19 | |||
20 | } | ||
21 | } | ||
22 | } | ||
diff --git a/ConvertToPlugins/src/world/World.cs b/ConvertToPlugins/src/world/World.cs new file mode 100644 index 0000000..8427a38 --- /dev/null +++ b/ConvertToPlugins/src/world/World.cs | |||
@@ -0,0 +1,117 @@ | |||
1 | using System; | ||
2 | using libsecondlife; | ||
3 | using libsecondlife.Packets; | ||
4 | using System.Collections.Generic; | ||
5 | using System.Text; | ||
6 | using PhysicsSystem; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class World | ||
11 | { | ||
12 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | ||
13 | public float[] LandMap; | ||
14 | public ScriptEngine Scripts; | ||
15 | public uint _localNumber=0; | ||
16 | private PhysicsScene phyScene; | ||
17 | private float timeStep= 0.1f; | ||
18 | private libsecondlife.TerrainManager TerrainManager; | ||
19 | |||
20 | private Random Rand = new Random(); | ||
21 | private uint _primCount = 702000; | ||
22 | |||
23 | public World() | ||
24 | { | ||
25 | ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); | ||
26 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | ||
27 | |||
28 | ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); | ||
29 | TerrainManager = new TerrainManager(new SecondLife()); | ||
30 | |||
31 | // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance"); | ||
32 | // Initialise this only after the world has loaded | ||
33 | // Scripts = new ScriptEngine(this); | ||
34 | } | ||
35 | |||
36 | public PhysicsScene PhysScene | ||
37 | { | ||
38 | set | ||
39 | { | ||
40 | this.phyScene = value; | ||
41 | } | ||
42 | get | ||
43 | { | ||
44 | return(this.phyScene); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public void Update() | ||
49 | { | ||
50 | |||
51 | if(this.phyScene.IsThreaded) | ||
52 | { | ||
53 | this.phyScene.GetResults(); | ||
54 | |||
55 | } | ||
56 | |||
57 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
58 | { | ||
59 | Entities[UUID].addForces(); | ||
60 | } | ||
61 | |||
62 | this.phyScene.Simulate(timeStep); | ||
63 | |||
64 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
65 | { | ||
66 | Entities[UUID].update(); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | public void SendLayerData(OpenSimClient RemoteClient) { | ||
71 | int[] patches = new int[4]; | ||
72 | |||
73 | for (int y = 0; y < 16; y++) | ||
74 | { | ||
75 | for (int x = 0; x < 16; x = x + 4) | ||
76 | { | ||
77 | patches[0] = x + 0 + y * 16; | ||
78 | patches[1] = x + 1 + y * 16; | ||
79 | patches[2] = x + 2 + y * 16; | ||
80 | patches[3] = x + 3 + y * 16; | ||
81 | |||
82 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); | ||
83 | RemoteClient.OutPacket(layerpack); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | public void AddViewerAgent(OpenSimClient AgentClient) { | ||
89 | ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
90 | Avatar NewAvatar = new Avatar(AgentClient); | ||
91 | ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
92 | ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
93 | NewAvatar.SendRegionHandshake(this); | ||
94 | |||
95 | NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z)); | ||
96 | //this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | ||
97 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | ||
98 | } | ||
99 | |||
100 | public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient) | ||
101 | { | ||
102 | ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); | ||
103 | Primitive prim = new Primitive(); | ||
104 | prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); | ||
105 | this.Entities.Add(prim.uuid, prim); | ||
106 | this._primCount++; | ||
107 | } | ||
108 | |||
109 | public bool Backup() { | ||
110 | /* TODO: Save the current world entities state. */ | ||
111 | |||
112 | return false; | ||
113 | } | ||
114 | |||
115 | |||
116 | } | ||
117 | } | ||
diff --git a/ConvertToPlugins/src/world/scripting/IScript.cs b/ConvertToPlugins/src/world/scripting/IScript.cs new file mode 100644 index 0000000..550594d --- /dev/null +++ b/ConvertToPlugins/src/world/scripting/IScript.cs | |||
@@ -0,0 +1,16 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world.scripting | ||
6 | { | ||
7 | public interface IScriptHost { | ||
8 | bool Register(IScript iscript); | ||
9 | } | ||
10 | public interface IScript | ||
11 | { | ||
12 | string Name{get;set;} | ||
13 | IScriptHost Host{get;set;} | ||
14 | void Show(); | ||
15 | } | ||
16 | } | ||