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.cs718
1 files changed, 718 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs
new file mode 100644
index 0000000..7c61c90
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Scene.cs
@@ -0,0 +1,718 @@
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.Region.Scripting;
43using OpenSim.Terrain;
44using OpenGrid.Framework.Communications;
45
46
47namespace OpenSim.Region.Scenes
48{
49 public delegate bool FilterAvatarList(Avatar avatar);
50
51 public partial class Scene : SceneBase, ILocalStorageReceiver, IScriptAPI
52 {
53 protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
54 protected Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
55 protected Dictionary<libsecondlife.LLUUID, Primitive> Prims;
56 private PhysicsScene phyScene;
57 private float timeStep = 0.1f;
58 public ILocalStorage localStorage;
59 private Random Rand = new Random();
60 private uint _primCount = 702000;
61 private int storageCount;
62 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
63 private Dictionary<string, ScriptFactory> m_scripts;
64 private Mutex updateLock;
65 public string m_datastore;
66 protected AuthenticateSessionsBase authenticateHandler;
67 protected RegionCommsHostBase regionCommsHost;
68 protected RegionServerCommsManager commsManager;
69
70 public ParcelManager parcelManager;
71 public EstateManager estateManager;
72
73 #region Properties
74 /// <summary>
75 ///
76 /// </summary>
77 public PhysicsScene PhysScene
78 {
79 set
80 {
81 this.phyScene = value;
82 }
83 get
84 {
85 return (this.phyScene);
86 }
87 }
88
89 #endregion
90
91 #region Constructors
92 /// <summary>
93 /// Creates a new World class, and a region to go with it.
94 /// </summary>
95 /// <param name="clientThreads">Dictionary to contain client threads</param>
96 /// <param name="regionHandle">Region Handle for this region</param>
97 /// <param name="regionName">Region Name for this region</param>
98 public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, RegionServerCommsManager commsMan)
99 {
100 try
101 {
102 updateLock = new Mutex(false);
103 this.authenticateHandler = authen;
104 this.commsManager = commsMan;
105 m_clientThreads = clientThreads;
106 m_regInfo = regInfo;
107 m_regionHandle = m_regInfo.RegionHandle;
108 m_regionName = m_regInfo.RegionName;
109 this.m_datastore = m_regInfo.DataStore;
110 this.RegisterRegionWithComms();
111
112 parcelManager = new ParcelManager(this, this.m_regInfo);
113 estateManager = new EstateManager(this, this.m_regInfo);
114
115 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
116 m_scripts = new Dictionary<string, ScriptFactory>();
117
118 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating new entitities instance");
119 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
120 Avatars = new Dictionary<LLUUID, Avatar>();
121 Prims = new Dictionary<LLUUID, Primitive>();
122
123 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs - creating LandMap");
124 TerrainManager = new TerrainManager(new SecondLife());
125 Terrain = new TerrainEngine();
126 Avatar.SetupTemplate("avatar-texture.dat");
127
128 Avatar.LoadAnims();
129
130 //this.SetDefaultScripts();
131 //this.LoadScriptEngines();
132
133
134 }
135 catch (Exception e)
136 {
137 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "World.cs: Constructor failed with exception " + e.ToString());
138 }
139 }
140 #endregion
141
142 /// <summary>
143 ///
144 /// </summary>
145 public void StartTimer()
146 {
147 m_heartbeatTimer.Enabled = true;
148 m_heartbeatTimer.Interval = 100;
149 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
150 }
151
152
153 #region Update Methods
154
155
156 /// <summary>
157 /// Performs per-frame updates regularly
158 /// </summary>
159 /// <param name="sender"></param>
160 /// <param name="e"></param>
161 void Heartbeat(object sender, System.EventArgs e)
162 {
163 this.Update();
164 }
165
166 /// <summary>
167 /// Performs per-frame updates on the world, this should be the central world loop
168 /// </summary>
169 public override void Update()
170 {
171 updateLock.WaitOne();
172 try
173 {
174 if (this.phyScene.IsThreaded)
175 {
176 this.phyScene.GetResults();
177
178 }
179
180 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
181 {
182 Entities[UUID].addForces();
183 }
184
185 lock (this.m_syncRoot)
186 {
187 this.phyScene.Simulate(timeStep);
188 }
189
190 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
191 {
192 Entities[UUID].update();
193 }
194
195 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
196 {
197 scriptHandler.OnFrame();
198 }
199 foreach (IScriptEngine scripteng in this.scriptEngines.Values)
200 {
201 scripteng.OnFrame();
202 }
203 //backup world data
204 this.storageCount++;
205 if (storageCount > 1200) //set to how often you want to backup
206 {
207 this.Backup();
208 storageCount = 0;
209 }
210 }
211 catch (Exception e)
212 {
213 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: Update() - Failed with exception " + e.ToString());
214 }
215 updateLock.ReleaseMutex();
216
217 }
218
219 /// <summary>
220 ///
221 /// </summary>
222 /// <returns></returns>
223 public bool Backup()
224 {
225 /*
226 try
227 {
228 // Terrain backup routines
229 if (Terrain.tainted > 0)
230 {
231 Terrain.tainted = 0;
232 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain tainted, saving.");
233 localStorage.SaveMap(Terrain.getHeights1D());
234 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Terrain saved, informing Physics.");
235 lock (this.m_syncRoot)
236 {
237 phyScene.SetTerrain(Terrain.getHeights1D());
238 }
239 }
240
241 // Primitive backup routines
242 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: Backup() - Backing up Primitives");
243 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
244 {
245 Entities[UUID].BackUp();
246 }
247
248 //Parcel backup routines
249 ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count];
250 int i = 0;
251 foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values)
252 {
253 parcels[i] = parcel.parcelData;
254 i++;
255 }
256 localStorage.SaveParcels(parcels);
257
258 // Backup successful
259 return true;
260 }
261 catch (Exception e)
262 {
263 // Backup failed
264 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString());
265 return false;
266 }
267 */
268 return true;
269 }
270 #endregion
271
272 #region Setup Methods
273 /// <summary>
274 /// Loads a new storage subsystem from a named library
275 /// </summary>
276 /// <param name="dllName">Storage Library</param>
277 /// <returns>Successful or not</returns>
278 public bool LoadStorageDLL(string dllName)
279 {
280 try
281 {
282 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
283 ILocalStorage store = null;
284
285 foreach (Type pluginType in pluginAssembly.GetTypes())
286 {
287 if (pluginType.IsPublic)
288 {
289 if (!pluginType.IsAbstract)
290 {
291 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
292
293 if (typeInterface != null)
294 {
295 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
296 store = plug;
297
298 store.Initialise(this.m_datastore);
299 break;
300 }
301
302 typeInterface = null;
303 }
304 }
305 }
306 pluginAssembly = null;
307 this.localStorage = store;
308 return (store == null);
309 }
310 catch (Exception e)
311 {
312 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
313 return false;
314 }
315 }
316
317 #endregion
318
319 #region Regenerate Terrain
320
321 /// <summary>
322 /// Rebuilds the terrain using a procedural algorithm
323 /// </summary>
324 public void RegenerateTerrain()
325 {
326 try
327 {
328 Terrain.hills();
329
330 lock (this.m_syncRoot)
331 {
332 this.phyScene.SetTerrain(Terrain.getHeights1D());
333 }
334 this.localStorage.SaveMap(this.Terrain.getHeights1D());
335
336 foreach (IClientAPI client in m_clientThreads.Values)
337 {
338 this.SendLayerData(client);
339 }
340
341 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
342 {
343 Entities[UUID].LandRenegerated();
344 }
345 }
346 catch (Exception e)
347 {
348 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
349 }
350 }
351
352 /// <summary>
353 /// Rebuilds the terrain using a 2D float array
354 /// </summary>
355 /// <param name="newMap">256,256 float array containing heights</param>
356 public void RegenerateTerrain(float[,] newMap)
357 {
358 try
359 {
360 this.Terrain.setHeights2D(newMap);
361 lock (this.m_syncRoot)
362 {
363 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
364 }
365 this.localStorage.SaveMap(this.Terrain.getHeights1D());
366
367 foreach (IClientAPI client in m_clientThreads.Values)
368 {
369 this.SendLayerData(client);
370 }
371
372 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
373 {
374 Entities[UUID].LandRenegerated();
375 }
376 }
377 catch (Exception e)
378 {
379 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
380 }
381 }
382
383 /// <summary>
384 /// Rebuilds the terrain assuming changes occured at a specified point[?]
385 /// </summary>
386 /// <param name="changes">???</param>
387 /// <param name="pointx">???</param>
388 /// <param name="pointy">???</param>
389 public void RegenerateTerrain(bool changes, int pointx, int pointy)
390 {
391 try
392 {
393 if (changes)
394 {
395 /* Dont save here, rely on tainting system instead */
396
397 foreach (IClientAPI client in m_clientThreads.Values)
398 {
399 this.SendLayerData(pointx, pointy, client);
400 }
401 }
402 }
403 catch (Exception e)
404 {
405 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
406 }
407 }
408
409 #endregion
410
411 #region Load Terrain
412 /// <summary>
413 /// Loads the World heightmap
414 /// </summary>
415 public override void LoadWorldMap()
416 {
417 try
418 {
419 float[] map = this.localStorage.LoadWorld();
420 if (map == null)
421 {
422 Console.WriteLine("creating new terrain");
423 this.Terrain.hills();
424
425 this.localStorage.SaveMap(this.Terrain.getHeights1D());
426 }
427 else
428 {
429 this.Terrain.setHeights1D(map);
430 }
431 }
432 catch (Exception e)
433 {
434 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
435 }
436 }
437 #endregion
438
439 #region Primitives Methods
440
441
442 /// <summary>
443 /// Loads the World's objects
444 /// </summary>
445 public void LoadPrimsFromStorage()
446 {
447 try
448 {
449 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: LoadPrimsFromStorage() - Loading primitives");
450 this.localStorage.LoadPrimitives(this);
451 }
452 catch (Exception e)
453 {
454 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
455 }
456 }
457
458 /// <summary>
459 /// Loads a specific object from storage
460 /// </summary>
461 /// <param name="prim">The object to load</param>
462 public void PrimFromStorage(PrimData prim)
463 {
464
465 }
466
467 /// <summary>
468 ///
469 /// </summary>
470 /// <param name="addPacket"></param>
471 /// <param name="agentClient"></param>
472 public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
473 {
474 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
475 }
476
477 /// <summary>
478 ///
479 /// </summary>
480 /// <param name="addPacket"></param>
481 /// <param name="ownerID"></param>
482 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
483 {
484 try
485 {
486 // MainConsole.Instance.Notice("World.cs: AddNewPrim() - Creating new prim");
487 Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount);
488
489 this.Entities.Add(prim.uuid, prim);
490 this._primCount++;
491 }
492 catch (Exception e)
493 {
494 // MainConsole.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
495 }
496 }
497
498 #endregion
499
500 #region Add/Remove Avatar Methods
501
502 /// <summary>
503 ///
504 /// </summary>
505 /// <param name="remoteClient"></param
506 /// <param name="agentID"></param>
507 /// <param name="child"></param>
508 public override void AddNewAvatar(IClientAPI remoteClient, LLUUID agentID, bool child)
509 {
510 remoteClient.OnRegionHandShakeReply += new GenericCall(this.SendLayerData);
511 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
512 remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat);
513 remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours);
514 remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim);
515 remoteClient.OnUpdatePrimPosition += new UpdatePrimVector(this.UpdatePrimPosition);
516
517 /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
518 remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);
519 remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest);
520 remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest);
521 remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage);
522 */
523
524 Avatar newAvatar = null;
525 try
526 {
527 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
528 newAvatar = new Avatar(remoteClient, this, m_clientThreads, this.m_regInfo);
529 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Adding new avatar to world");
530 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Starting RegionHandshake ");
531
532 //newAvatar.SendRegionHandshake();
533 this.estateManager.sendRegionHandshake(remoteClient);
534
535 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
536 lock (this.m_syncRoot)
537 {
538 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
539 }
540
541 lock (Entities)
542 {
543 if (!Entities.ContainsKey(agentID))
544 {
545 this.Entities.Add(agentID, newAvatar);
546 }
547 else
548 {
549 Entities[agentID] = newAvatar;
550 }
551 }
552 lock (Avatars)
553 {
554 if (Avatars.ContainsKey(agentID))
555 {
556 Avatars[agentID] = newAvatar;
557 }
558 else
559 {
560 this.Avatars.Add(agentID, newAvatar);
561 }
562 }
563 }
564 catch (Exception e)
565 {
566 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
567 }
568 return;
569 }
570
571 /// <summary>
572 ///
573 /// </summary>
574 protected void InformClientOfNeighbours(IClientAPI remoteClient)
575 {
576 // Console.WriteLine("informing client of neighbouring regions");
577 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
578
579 //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions");
580 if (neighbours != null)
581 {
582 for (int i = 0; i < neighbours.Count; i++)
583 {
584 // Console.WriteLine("sending neighbours data");
585 AgentCircuitData agent = remoteClient.RequestClientInfo();
586 agent.BaseFolder = LLUUID.Zero;
587 agent.InventoryFolder = LLUUID.Zero;
588 agent.startpos = new LLVector3(128, 128, 70);
589 this.commsManager.InterSims.InformNeighbourOfChildAgent(neighbours[i].RegionHandle, agent);
590 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].IPListenAddr), (ushort)neighbours[i].IPListenPort);
591 }
592 }
593 }
594
595 /// <summary>
596 ///
597 /// </summary>
598 /// <param name="agentID"></param>
599 public override void RemoveAvatar(LLUUID agentID)
600 {
601 return;
602 }
603 #endregion
604
605 #region Request Avatars List Methods
606 //The idea is to have a group of method that return a list of avatars meeting some requirement
607 // ie it could be all Avatars within a certain range of the calling prim/avatar.
608
609 /// <summary>
610 /// Request a List of all Avatars in this World
611 /// </summary>
612 /// <returns></returns>
613 public List<Avatar> RequestAvatarList()
614 {
615 List<Avatar> result = new List<Avatar>();
616
617 foreach (Avatar avatar in Avatars.Values)
618 {
619 result.Add(avatar);
620 }
621
622 return result;
623 }
624
625 /// <summary>
626 /// Request a filtered list of Avatars in this World
627 /// </summary>
628 /// <returns></returns>
629 public List<Avatar> RequestAvatarList(FilterAvatarList filter)
630 {
631 List<Avatar> result = new List<Avatar>();
632
633 foreach (Avatar avatar in Avatars.Values)
634 {
635 if (filter(avatar))
636 {
637 result.Add(avatar);
638 }
639 }
640
641 return result;
642 }
643
644 /// <summary>
645 /// Request a Avatar by UUID
646 /// </summary>
647 /// <param name="avatarID"></param>
648 /// <returns></returns>
649 public Avatar RequestAvatar(LLUUID avatarID)
650 {
651 if (this.Avatars.ContainsKey(avatarID))
652 {
653 return Avatars[avatarID];
654 }
655 return null;
656 }
657 #endregion
658
659 #region ShutDown
660 /// <summary>
661 /// Tidy before shutdown
662 /// </summary>
663 public override void Close()
664 {
665 try
666 {
667 this.localStorage.ShutDown();
668 }
669 catch (Exception e)
670 {
671 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString());
672 }
673 }
674 #endregion
675
676 #region RegionCommsHost
677
678 /// <summary>
679 ///
680 /// </summary>
681 public void RegisterRegionWithComms()
682 {
683 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo);
684 if (this.regionCommsHost != null)
685 {
686 this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection);
687 }
688 }
689
690 /// <summary>
691 ///
692 /// </summary>
693 /// <param name="regionHandle"></param>
694 /// <param name="agent"></param>
695 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
696 {
697 // Console.WriteLine("World.cs - add new user connection");
698 //should just check that its meant for this region
699 if (regionHandle == this.m_regInfo.RegionHandle)
700 {
701 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
702 }
703 }
704
705 #endregion
706
707 /// <summary>
708 ///
709 /// </summary>
710 /// <param name="px"></param>
711 /// <param name="py"></param>
712 /// <param name="RemoteClient"></param>
713 public override void SendLayerData(int px, int py, IClientAPI RemoteClient)
714 {
715 RemoteClient.SendLayerData( Terrain.getHeights1D() );
716 }
717 }
718}