aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/Scene.cs')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Scene.cs781
1 files changed, 0 insertions, 781 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs
deleted file mode 100644
index f7d90fa..0000000
--- a/OpenSim/OpenSim.Region/Scenes/Scene.cs
+++ /dev/null
@@ -1,781 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using libsecondlife;
30using libsecondlife.Packets;
31using System.Collections.Generic;
32using System.Text;
33using System.Reflection;
34using System.IO;
35using System.Threading;
36using System.Timers;
37using OpenSim.Physics.Manager;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Inventory;
41using OpenSim.Framework;
42using OpenSim.Terrain;
43using OpenGrid.Framework.Communications;
44using OpenSim.Caches;
45using OpenSim.Region;
46using OpenSim.Servers;
47using OpenSim.Scripting;
48
49namespace OpenSim.Region.Scenes
50{
51 public delegate bool FilterAvatarList(ScenePresence avatar);
52
53 public partial class Scene : SceneBase, ILocalStorageReceiver, IScriptAPI
54 {
55 protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
56 protected Dictionary<libsecondlife.LLUUID, ScenePresence> Avatars;
57 protected Dictionary<libsecondlife.LLUUID, Primitive> Prims;
58 private PhysicsScene phyScene;
59 private float timeStep = 0.1f;
60 private Random Rand = new Random();
61 private uint _primCount = 702000;
62 private int storageCount;
63 private Mutex updateLock;
64
65 protected AuthenticateSessionsBase authenticateHandler;
66 protected RegionCommsListener regionCommsHost;
67 protected CommunicationsManager commsManager;
68
69 protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
70 protected BaseHttpServer httpListener;
71
72 public ParcelManager parcelManager;
73 public EstateManager estateManager;
74 public EventManager eventManager;
75 public ScriptManager scriptManager;
76
77 #region Properties
78 /// <summary>
79 ///
80 /// </summary>
81 public PhysicsScene PhysScene
82 {
83 set
84 {
85 this.phyScene = value;
86 }
87 get
88 {
89 return (this.phyScene);
90 }
91 }
92
93 #endregion
94
95 #region Constructors
96 /// <summary>
97 /// Creates a new World class, and a region to go with it.
98 /// </summary>
99 /// <param name="clientThreads">Dictionary to contain client threads</param>
100 /// <param name="regionHandle">Region Handle for this region</param>
101 /// <param name="regionName">Region Name for this region</param>
102 public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
103 {
104 try
105 {
106 updateLock = new Mutex(false);
107 this.authenticateHandler = authen;
108 this.commsManager = commsMan;
109 this.assetCache = assetCach;
110 m_clientThreads = clientThreads;
111 m_regInfo = regInfo;
112 m_regionHandle = m_regInfo.RegionHandle;
113 m_regionName = m_regInfo.RegionName;
114 this.m_datastore = m_regInfo.DataStore;
115 this.RegisterRegionWithComms();
116
117 parcelManager = new ParcelManager(this, this.m_regInfo);
118 estateManager = new EstateManager(this, this.m_regInfo);
119 scriptManager = new ScriptManager(this);
120 eventManager = new EventManager();
121
122 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating new entitities instance");
123 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
124 Avatars = new Dictionary<LLUUID, ScenePresence>();
125 Prims = new Dictionary<LLUUID, Primitive>();
126
127 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap");
128 Terrain = new TerrainEngine();
129
130 ScenePresence.LoadAnims();
131 this.httpListener = httpServer;
132
133 }
134 catch (Exception e)
135 {
136 OpenSim.Framework.Console.MainLog.Instance.Error( "World.cs: Constructor failed with exception " + e.ToString());
137 }
138 }
139 #endregion
140
141 /// <summary>
142 ///
143 /// </summary>
144 public void StartTimer()
145 {
146 m_heartbeatTimer.Enabled = true;
147 m_heartbeatTimer.Interval = 100;
148 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
149 }
150
151
152 #region Update Methods
153
154
155 /// <summary>
156 /// Performs per-frame updates regularly
157 /// </summary>
158 /// <param name="sender"></param>
159 /// <param name="e"></param>
160 void Heartbeat(object sender, System.EventArgs e)
161 {
162 this.Update();
163 }
164
165 /// <summary>
166 /// Performs per-frame updates on the world, this should be the central world loop
167 /// </summary>
168 public override void Update()
169 {
170 updateLock.WaitOne();
171 try
172 {
173 if (this.phyScene.IsThreaded)
174 {
175 this.phyScene.GetResults();
176
177 }
178
179 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
180 {
181 Entities[UUID].updateMovement();
182 }
183
184 lock (this.m_syncRoot)
185 {
186 this.phyScene.Simulate(timeStep);
187 }
188
189 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
190 {
191 Entities[UUID].update();
192 }
193
194 // General purpose event manager
195 eventManager.TriggerOnFrame();
196
197 //backup world data
198 this.storageCount++;
199 if (storageCount > 1200) //set to how often you want to backup
200 {
201 this.Backup();
202 storageCount = 0;
203 }
204 }
205 catch (Exception e)
206 {
207 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
208 }
209 updateLock.ReleaseMutex();
210
211 }
212
213 /// <summary>
214 ///
215 /// </summary>
216 /// <returns></returns>
217 public bool Backup()
218 {
219 /*
220 try
221 {
222 // Terrain backup routines
223 if (Terrain.tainted > 0)
224 {
225 Terrain.tainted = 0;
226 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain tainted, saving.");
227 localStorage.SaveMap(Terrain.getHeights1D());
228 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain saved, informing Physics.");
229 lock (this.m_syncRoot)
230 {
231 phyScene.SetTerrain(Terrain.getHeights1D());
232 }
233 }
234
235 // Primitive backup routines
236 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Backing up Primitives");
237 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
238 {
239 Entities[UUID].BackUp();
240 }
241
242 //Parcel backup routines
243 ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count];
244 int i = 0;
245 foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values)
246 {
247 parcels[i] = parcel.parcelData;
248 i++;
249 }
250 localStorage.SaveParcels(parcels);
251
252 // Backup successful
253 return true;
254 }
255 catch (Exception e)
256 {
257 // Backup failed
258 OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString());
259 return false;
260 }
261 */
262 return true;
263 }
264 #endregion
265
266 #region Regenerate Terrain
267
268 /// <summary>
269 /// Rebuilds the terrain using a procedural algorithm
270 /// </summary>
271 public void RegenerateTerrain()
272 {
273 try
274 {
275 Terrain.hills();
276
277 lock (this.m_syncRoot)
278 {
279 this.phyScene.SetTerrain(Terrain.getHeights1D());
280 }
281 this.localStorage.SaveMap(this.Terrain.getHeights1D());
282
283 foreach (IClientAPI client in m_clientThreads.Values)
284 {
285 this.SendLayerData(client);
286 }
287
288 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
289 {
290 Entities[UUID].LandRenegerated();
291 }
292 }
293 catch (Exception e)
294 {
295 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
296 }
297 }
298
299 /// <summary>
300 /// Rebuilds the terrain using a 2D float array
301 /// </summary>
302 /// <param name="newMap">256,256 float array containing heights</param>
303 public void RegenerateTerrain(float[,] newMap)
304 {
305 try
306 {
307 this.Terrain.setHeights2D(newMap);
308 lock (this.m_syncRoot)
309 {
310 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
311 }
312 this.localStorage.SaveMap(this.Terrain.getHeights1D());
313
314 foreach (IClientAPI client in m_clientThreads.Values)
315 {
316 this.SendLayerData(client);
317 }
318
319 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
320 {
321 Entities[UUID].LandRenegerated();
322 }
323 }
324 catch (Exception e)
325 {
326 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
327 }
328 }
329
330 /// <summary>
331 /// Rebuilds the terrain assuming changes occured at a specified point[?]
332 /// </summary>
333 /// <param name="changes">???</param>
334 /// <param name="pointx">???</param>
335 /// <param name="pointy">???</param>
336 public void RegenerateTerrain(bool changes, int pointx, int pointy)
337 {
338 try
339 {
340 if (changes)
341 {
342 /* Dont save here, rely on tainting system instead */
343
344 foreach (IClientAPI client in m_clientThreads.Values)
345 {
346 this.SendLayerData(pointx, pointy, client);
347 }
348 }
349 }
350 catch (Exception e)
351 {
352 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
353 }
354 }
355
356 #endregion
357
358 #region Load Terrain
359 /// <summary>
360 /// Loads the World heightmap
361 /// </summary>
362 ///
363 public override void LoadWorldMap()
364 {
365 try
366 {
367 float[] map = this.localStorage.LoadWorld();
368 if (map == null)
369 {
370 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
371 {
372 Console.WriteLine("No default terrain, procedurally generating...");
373 this.Terrain.hills();
374
375 this.localStorage.SaveMap(this.Terrain.getHeights1D());
376 }
377 else
378 {
379 try
380 {
381 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile);
382 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier;
383 }
384 catch
385 {
386 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
387 Terrain.hills();
388 }
389 this.localStorage.SaveMap(this.Terrain.getHeights1D());
390 }
391 }
392 else
393 {
394 this.Terrain.setHeights1D(map);
395 }
396
397 CreateTerrainTexture();
398
399 }
400 catch (Exception e)
401 {
402 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
403 }
404 }
405
406 /// <summary>
407 ///
408 /// </summary>
409 private void CreateTerrainTexture()
410 {
411 //create a texture asset of the terrain
412 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png");
413 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
414 AssetBase asset = new AssetBase();
415 asset.FullID = this.m_regInfo.estateSettings.terrainImageID;
416 asset.Data = data;
417 asset.Name = "terrainImage";
418 asset.Type = 0;
419 this.assetCache.AddAsset(asset);
420 }
421 #endregion
422
423 #region Primitives Methods
424
425
426 /// <summary>
427 /// Loads the World's objects
428 /// </summary>
429 public void LoadPrimsFromStorage()
430 {
431 try
432 {
433 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: LoadPrimsFromStorage() - Loading primitives");
434 this.localStorage.LoadPrimitives(this);
435 }
436 catch (Exception e)
437 {
438 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
439 }
440 }
441
442 /// <summary>
443 /// Loads a specific object from storage
444 /// </summary>
445 /// <param name="prim">The object to load</param>
446 public void PrimFromStorage(PrimData prim)
447 {
448
449 }
450
451 /// <summary>
452 ///
453 /// </summary>
454 /// <param name="addPacket"></param>
455 /// <param name="agentClient"></param>
456 public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
457 {
458 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
459 }
460
461 /// <summary>
462 ///
463 /// </summary>
464 /// <param name="addPacket"></param>
465 /// <param name="ownerID"></param>
466 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
467 {
468 try
469 {
470 Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount);
471
472 this.Entities.Add(prim.uuid, prim);
473 this._primCount++;
474
475 // Trigger event for listeners
476 eventManager.TriggerOnNewPrimitive(prim);
477 }
478 catch (Exception e)
479 {
480 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
481 }
482 }
483
484 #endregion
485
486 #region Add/Remove Avatar Methods
487
488 /// <summary>
489 ///
490 /// </summary>
491 /// <param name="remoteClient"></param
492 /// <param name="agentID"></param>
493 /// <param name="child"></param>
494 public override void AddNewClient(IClientAPI remoteClient, LLUUID agentID, bool child)
495 {
496 remoteClient.OnRegionHandShakeReply += this.SendLayerData;
497 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
498 remoteClient.OnChatFromViewer += this.SimChat;
499 remoteClient.OnRequestWearables += this.InformClientOfNeighbours;
500 remoteClient.OnAddPrim += this.AddNewPrim;
501 remoteClient.OnUpdatePrimPosition += this.UpdatePrimPosition;
502 remoteClient.OnRequestMapBlocks += this.RequestMapBlocks;
503 remoteClient.OnTeleportLocationRequest += this.RequestTeleportLocation;
504 //remoteClient.OnObjectSelect += this.SelectPrim;
505 remoteClient.OnGrapUpdate += this.MoveObject;
506
507 /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
508 remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);
509 remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest);
510 remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest);
511 remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage);
512 */
513
514 ScenePresence newAvatar = null;
515 try
516 {
517
518 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
519 newAvatar = new ScenePresence(remoteClient, this, this.m_regInfo);
520 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Adding new avatar to world");
521 OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Starting RegionHandshake ");
522
523 //newAvatar.SendRegionHandshake();
524 this.estateManager.sendRegionHandshake(remoteClient);
525
526 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
527 lock (this.m_syncRoot)
528 {
529 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
530 }
531
532 lock (Entities)
533 {
534 if (!Entities.ContainsKey(agentID))
535 {
536 this.Entities.Add(agentID, newAvatar);
537 }
538 else
539 {
540 Entities[agentID] = newAvatar;
541 }
542 }
543 lock (Avatars)
544 {
545 if (Avatars.ContainsKey(agentID))
546 {
547 Avatars[agentID] = newAvatar;
548 }
549 else
550 {
551 this.Avatars.Add(agentID, newAvatar);
552 }
553 }
554 }
555 catch (Exception e)
556 {
557 OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
558 }
559 return;
560 }
561
562
563
564 /// <summary>
565 ///
566 /// </summary>
567 /// <param name="agentID"></param>
568 public override void RemoveClient(LLUUID agentID)
569 {
570 eventManager.TriggerOnRemovePresence(agentID);
571
572 return;
573 }
574 #endregion
575
576 #region Request Avatars List Methods
577 //The idea is to have a group of method that return a list of avatars meeting some requirement
578 // ie it could be all Avatars within a certain range of the calling prim/avatar.
579
580 /// <summary>
581 /// Request a List of all Avatars in this World
582 /// </summary>
583 /// <returns></returns>
584 public List<ScenePresence> RequestAvatarList()
585 {
586 List<ScenePresence> result = new List<ScenePresence>();
587
588 foreach (ScenePresence avatar in Avatars.Values)
589 {
590 result.Add(avatar);
591 }
592
593 return result;
594 }
595
596 /// <summary>
597 /// Request a filtered list of Avatars in this World
598 /// </summary>
599 /// <returns></returns>
600 public List<ScenePresence> RequestAvatarList(FilterAvatarList filter)
601 {
602 List<ScenePresence> result = new List<ScenePresence>();
603
604 foreach (ScenePresence avatar in Avatars.Values)
605 {
606 if (filter(avatar))
607 {
608 result.Add(avatar);
609 }
610 }
611
612 return result;
613 }
614
615 /// <summary>
616 /// Request a Avatar by UUID
617 /// </summary>
618 /// <param name="avatarID"></param>
619 /// <returns></returns>
620 public ScenePresence RequestAvatar(LLUUID avatarID)
621 {
622 if (this.Avatars.ContainsKey(avatarID))
623 {
624 return Avatars[avatarID];
625 }
626 return null;
627 }
628 #endregion
629
630
631 #region RegionCommsHost
632
633 /// <summary>
634 ///
635 /// </summary>
636 public void RegisterRegionWithComms()
637 {
638 GridInfo gridSettings = new GridInfo();
639 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo,gridSettings);
640 if (this.regionCommsHost != null)
641 {
642 this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection);
643 this.regionCommsHost.OnAvatarCrossingIntoRegion += new AgentCrossing(this.AgentCrossing);
644 }
645 }
646
647 /// <summary>
648 ///
649 /// </summary>
650 /// <param name="regionHandle"></param>
651 /// <param name="agent"></param>
652 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
653 {
654 // Console.WriteLine("World.cs - add new user connection");
655 //should just check that its meant for this region
656 if (regionHandle == this.m_regInfo.RegionHandle)
657 {
658 if (agent.CapsPath != "")
659 {
660 //Console.WriteLine("new user, so creating caps handler for it");
661 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.CommsIPListenAddr, 9000, agent.CapsPath, agent.AgentID);
662 cap.RegisterHandlers();
663 this.capsHandlers.Add(agent.AgentID, cap);
664 }
665 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
666 }
667 }
668
669 public void AgentCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
670 {
671 if (regionHandle == this.m_regInfo.RegionHandle)
672 {
673 if (this.Avatars.ContainsKey(agentID))
674 {
675 this.Avatars[agentID].MakeAvatar(position);
676 }
677 }
678 }
679
680 /// <summary>
681 ///
682 /// </summary>
683 public void InformClientOfNeighbours(IClientAPI remoteClient)
684 {
685 // Console.WriteLine("informing client of neighbouring regions");
686 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
687
688 //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions");
689 if (neighbours != null)
690 {
691 for (int i = 0; i < neighbours.Count; i++)
692 {
693 // Console.WriteLine("sending neighbours data");
694 AgentCircuitData agent = remoteClient.RequestClientInfo();
695 agent.BaseFolder = LLUUID.Zero;
696 agent.InventoryFolder = LLUUID.Zero;
697 agent.startpos = new LLVector3(128, 128, 70);
698 agent.child = true;
699 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
700 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr), (ushort)neighbours[i].CommsIPListenPort);
701 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
702 }
703 }
704 }
705
706 /// <summary>
707 ///
708 /// </summary>
709 /// <param name="regionHandle"></param>
710 /// <returns></returns>
711 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
712 {
713 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle);
714 }
715
716 /// <summary>
717 ///
718 /// </summary>
719 /// <param name="minX"></param>
720 /// <param name="minY"></param>
721 /// <param name="maxX"></param>
722 /// <param name="maxY"></param>
723 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
724 {
725 List<MapBlockData> mapBlocks;
726 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
727 remoteClient.SendMapBlock(mapBlocks);
728 }
729
730 /// <summary>
731 ///
732 /// </summary>
733 /// <param name="remoteClient"></param>
734 /// <param name="RegionHandle"></param>
735 /// <param name="position"></param>
736 /// <param name="lookAt"></param>
737 /// <param name="flags"></param>
738 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
739 {
740 if (regionHandle == this.m_regionHandle)
741 {
742 if (this.Avatars.ContainsKey(remoteClient.AgentId))
743 {
744 remoteClient.SendTeleportLocationStart();
745 remoteClient.SendLocalTeleport(position, lookAt, flags);
746 this.Avatars[remoteClient.AgentId].Teleport(position);
747 }
748 }
749 else
750 {
751 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle);
752 if (reg != null)
753 {
754 remoteClient.SendTeleportLocationStart();
755 AgentCircuitData agent = remoteClient.RequestClientInfo();
756 agent.BaseFolder = LLUUID.Zero;
757 agent.InventoryFolder = LLUUID.Zero;
758 agent.startpos = new LLVector3(128, 128, 70);
759 agent.child = true;
760 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
761 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
762 remoteClient.SendRegionTeleport(regionHandle, 13, reg.CommsIPListenAddr, (ushort)reg.CommsIPListenPort, 4, (1 << 4));
763 }
764 //remoteClient.SendTeleportCancel();
765 }
766 }
767
768 /// <summary>
769 ///
770 /// </summary>
771 /// <param name="regionhandle"></param>
772 /// <param name="agentID"></param>
773 /// <param name="position"></param>
774 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
775 {
776 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
777 }
778
779 #endregion
780 }
781}