aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/world/World.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/World.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/world/World.cs734
1 files changed, 0 insertions, 734 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/World.cs b/OpenSim/OpenSim.RegionServer/world/World.cs
deleted file mode 100644
index 69f3fda..0000000
--- a/OpenSim/OpenSim.RegionServer/world/World.cs
+++ /dev/null
@@ -1,734 +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 OpenSim.Physics.Manager;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types;
39using OpenSim.Framework.Terrain;
40using OpenSim.Framework.Inventory;
41using OpenSim.Assets;
42//using OpenSim.world.scripting;
43using OpenSim.RegionServer.world.scripting;
44using OpenSim.Terrain;
45using OpenSim.Framework.Console;
46
47namespace OpenSim.world
48{
49 public partial class World : WorldBase, ILocalStorageReceiver, IScriptAPI
50 {
51 public object LockPhysicsEngine = new object();
52 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
53 public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
54 //public ScriptEngine Scripts;
55 public uint _localNumber = 0;
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 public OpenSim.RegionServer.world.ParcelManager parcelManager;
67
68 #region Properties
69 public PhysicsScene PhysScene
70 {
71 set
72 {
73 this.phyScene = value;
74 }
75 get
76 {
77 return (this.phyScene);
78 }
79 }
80 #endregion
81
82 #region Constructors
83 /// <summary>
84 /// Creates a new World class, and a region to go with it.
85 /// </summary>
86 /// <param name="clientThreads">Dictionary to contain client threads</param>
87 /// <param name="regionHandle">Region Handle for this region</param>
88 /// <param name="regionName">Region Name for this region</param>
89 public World(Dictionary<uint, ClientView> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
90 {
91 try
92 {
93 updateLock = new Mutex(false);
94 m_clientThreads = clientThreads;
95 m_regionHandle = regionHandle;
96 m_regionName = regionName;
97 m_regInfo = regInfo;
98
99 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
100 m_scripts = new Dictionary<string, ScriptFactory>();
101
102 MainConsole.Instance.Notice("World.cs - creating new entitities instance");
103 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
104 Avatars = new Dictionary<LLUUID, Avatar>();
105 Prims = new Dictionary<LLUUID, Primitive>();
106
107 MainConsole.Instance.Notice("World.cs - creating LandMap");
108 TerrainManager = new TerrainManager(new SecondLife());
109 Terrain = new TerrainEngine();
110 Avatar.SetupTemplate("avatar-texture.dat");
111 // MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
112 // Initialise this only after the world has loaded
113 // Scripts = new ScriptEngine(this);
114 Avatar.LoadAnims();
115 this.SetDefaultScripts();
116 this.LoadScriptEngines();
117
118 }
119 catch (Exception e)
120 {
121 OpenSim.Framework.Console.MainConsole.Instance.Error("World.cs: Constructor failed with exception " + e.ToString());
122 }
123 }
124 #endregion
125
126 #region Script Methods
127 /// <summary>
128 /// Loads a new script into the specified entity
129 /// </summary>
130 /// <param name="entity">Entity to be scripted</param>
131 /// <param name="script">The script to load</param>
132 public void AddScript(Entity entity, Script script)
133 {
134 try
135 {
136 ScriptHandler scriptHandler = new ScriptHandler(script, entity, this);
137 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
138 }
139 catch (Exception e)
140 {
141 MainConsole.Instance.Warn("World.cs: AddScript() - Failed with exception " + e.ToString());
142 }
143 }
144
145 /// <summary>
146 /// Loads a new script into the specified entity, using a script loaded from a string.
147 /// </summary>
148 /// <param name="entity">The entity to be scripted</param>
149 /// <param name="scriptData">The string containing the script</param>
150 public void AddScript(Entity entity, string scriptData)
151 {
152 try
153 {
154 int scriptstart = 0;
155 int scriptend = 0;
156 string substring;
157 scriptstart = scriptData.LastIndexOf("<Script>");
158 scriptend = scriptData.LastIndexOf("</Script>");
159 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
160 substring = substring.Trim();
161 //Console.WriteLine("searching for script to add: " + substring);
162
163 ScriptFactory scriptFactory;
164 //Console.WriteLine("script string is " + substring);
165 if (substring.StartsWith("<ScriptEngine:"))
166 {
167 string substring1 = "";
168 string script = "";
169 // Console.WriteLine("searching for script engine");
170 substring1 = substring.Remove(0, 14);
171 int dev = substring1.IndexOf(',');
172 string sEngine = substring1.Substring(0, dev);
173 substring1 = substring1.Remove(0, dev + 1);
174 int end = substring1.IndexOf('>');
175 string sName = substring1.Substring(0, end);
176 //Console.WriteLine(" script info : " + sEngine + " , " + sName);
177 int startscript = substring.IndexOf('>');
178 script = substring.Remove(0, startscript + 1);
179 // Console.WriteLine("script data is " + script);
180 if (this.scriptEngines.ContainsKey(sEngine))
181 {
182 this.scriptEngines[sEngine].LoadScript(script, sName, entity.localid);
183 }
184 }
185 else if (this.m_scripts.TryGetValue(substring, out scriptFactory))
186 {
187 //Console.WriteLine("added script");
188 this.AddScript(entity, scriptFactory());
189 }
190 }
191 catch (Exception e)
192 {
193 MainConsole.Instance.Warn("World.cs: AddScript() - Failed with exception " + e.ToString());
194 }
195 }
196
197 #endregion
198
199 #region Update Methods
200 /// <summary>
201 /// Performs per-frame updates on the world, this should be the central world loop
202 /// </summary>
203 public override void Update()
204 {
205 updateLock.WaitOne();
206 try
207 {
208 if (this.phyScene.IsThreaded)
209 {
210 this.phyScene.GetResults();
211
212 }
213
214 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
215 {
216 Entities[UUID].addForces();
217 }
218
219 lock (this.LockPhysicsEngine)
220 {
221 this.phyScene.Simulate(timeStep);
222 }
223
224 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
225 {
226 Entities[UUID].update();
227 }
228
229 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
230 {
231 scriptHandler.OnFrame();
232 }
233 foreach (IScriptEngine scripteng in this.scriptEngines.Values)
234 {
235 scripteng.OnFrame();
236 }
237 //backup world data
238 this.storageCount++;
239 if (storageCount > 1200) //set to how often you want to backup
240 {
241 this.Backup();
242 storageCount = 0;
243 }
244 }
245 catch (Exception e)
246 {
247 MainConsole.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
248 }
249 updateLock.ReleaseMutex();
250 }
251
252 public bool Backup()
253 {
254 try
255 {
256 // Terrain backup routines
257 if (Terrain.tainted > 0)
258 {
259 Terrain.tainted = 0;
260 MainConsole.Instance.Notice("World.cs: Backup() - Terrain tainted, saving.");
261 localStorage.SaveMap(Terrain.getHeights1D());
262 MainConsole.Instance.Notice("World.cs: Backup() - Rebuilding world map image.");
263 Terrain.exportImage("map_" + m_regInfo.RegionName.ToLower() + ".png", "defaultstripe.png");
264 MainConsole.Instance.Notice("World.cs: Backup() - Terrain saved, informing Physics.");
265 phyScene.SetTerrain(Terrain.getHeights1D());
266
267 // Needs optimising to just send patches which have changed.
268 MainConsole.Instance.Notice("World.cs: Backup() - Terrain changed, informing Clients.");
269 foreach (ClientView client in m_clientThreads.Values)
270 {
271 this.SendLayerData(client);
272 }
273 }
274
275 // Primitive backup routines -- should only do if there's been a change.
276 MainConsole.Instance.Notice("World.cs: Backup() - Backing up Primitives");
277 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
278 {
279 Entities[UUID].BackUp();
280 }
281
282
283 //Parcel backup routines. Yay!
284 ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count];
285 int i = 0;
286 foreach(OpenSim.RegionServer.world.Parcel parcel in parcelManager.parcelList.Values)
287 {
288 parcels[i] = parcel.parcelData;
289 i++;
290 }
291 localStorage.SaveParcels(parcels);
292
293
294 // Backup successful
295 return true;
296 }
297 catch (Exception e)
298 {
299 // Backup failed
300 OpenSim.Framework.Console.MainConsole.Instance.Error("World.cs: Backup() - Backup Failed with exception " + e.ToString());
301 return false;
302 }
303 }
304 #endregion
305
306 #region Setup Methods
307 /// <summary>
308 /// Loads a new storage subsystem from a named library
309 /// </summary>
310 /// <param name="dllName">Storage Library</param>
311 /// <returns>Successful or not</returns>
312 public bool LoadStorageDLL(string dllName)
313 {
314 try
315 {
316 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
317 ILocalStorage store = null;
318
319 foreach (Type pluginType in pluginAssembly.GetTypes())
320 {
321 if (pluginType.IsPublic)
322 {
323 if (!pluginType.IsAbstract)
324 {
325 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
326
327 if (typeInterface != null)
328 {
329 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
330 store = plug;
331
332 store.Initialise(this.m_datastore);
333 break;
334 }
335
336 typeInterface = null;
337 }
338 }
339 }
340 pluginAssembly = null;
341 this.localStorage = store;
342 return (store == null);
343 }
344 catch (Exception e)
345 {
346 MainConsole.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
347 return false;
348 }
349 }
350
351 public void SetDefaultScripts()
352 {
353 this.m_scripts.Add("FollowRandomAvatar", delegate()
354 {
355 return new OpenSim.RegionServer.world.scripting.FollowRandomAvatar();
356 });
357 }
358
359 #endregion
360
361 #region Regenerate Terrain
362
363 /// <summary>
364 /// Rebuilds the terrain using a procedural algorithm
365 /// </summary>
366 public void RegenerateTerrain()
367 {
368 try
369 {
370 Terrain.hills();
371
372 lock (this.LockPhysicsEngine)
373 {
374 this.phyScene.SetTerrain(Terrain.getHeights1D());
375 }
376 this.localStorage.SaveMap(this.Terrain.getHeights1D());
377
378 foreach (ClientView client in m_clientThreads.Values)
379 {
380 this.SendLayerData(client);
381 }
382
383 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
384 {
385 Entities[UUID].LandRenegerated();
386 }
387 }
388 catch (Exception e)
389 {
390 MainConsole.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
391 }
392 }
393
394 /// <summary>
395 /// Rebuilds the terrain using a 2D float array
396 /// </summary>
397 /// <param name="newMap">256,256 float array containing heights</param>
398 public void RegenerateTerrain(float[,] newMap)
399 {
400 try
401 {
402 this.Terrain.setHeights2D(newMap);
403 lock (this.LockPhysicsEngine)
404 {
405 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
406 }
407 this.localStorage.SaveMap(this.Terrain.getHeights1D());
408
409 foreach (ClientView client in m_clientThreads.Values)
410 {
411 this.SendLayerData(client);
412 }
413
414 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
415 {
416 Entities[UUID].LandRenegerated();
417 }
418 }
419 catch (Exception e)
420 {
421 MainConsole.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
422 }
423 }
424
425 /// <summary>
426 /// Rebuilds the terrain assuming changes occured at a specified point[?]
427 /// </summary>
428 /// <param name="changes">???</param>
429 /// <param name="pointx">???</param>
430 /// <param name="pointy">???</param>
431 public void RegenerateTerrain(bool changes, int pointx, int pointy)
432 {
433 try
434 {
435 if (changes)
436 {
437 /* Dont save here, rely on tainting system instead */
438
439 foreach (ClientView client in m_clientThreads.Values)
440 {
441 this.SendLayerData(pointx, pointy, client);
442 }
443 }
444 }
445 catch (Exception e)
446 {
447 MainConsole.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
448 }
449 }
450
451 #endregion
452
453 #region Load Terrain
454 /// <summary>
455 /// Loads the World heightmap
456 /// </summary>
457 public override void LoadWorldMap()
458 {
459 try
460 {
461 float[] map = this.localStorage.LoadWorld();
462 if (map == null)
463 {
464 if (string.IsNullOrEmpty(this.m_regInfo.TerrainFile))
465 {
466 Console.WriteLine("No default terrain, procedurally generating...");
467 this.Terrain.hills();
468
469 this.localStorage.SaveMap(this.Terrain.getHeights1D());
470 }
471 else
472 {
473 try
474 {
475 this.Terrain.loadFromFileF32(this.m_regInfo.TerrainFile);
476 this.Terrain *= this.m_regInfo.TerrainMultiplier;
477 }
478 catch (Exception e)
479 {
480 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
481 Terrain.hills();
482 }
483 this.localStorage.SaveMap(this.Terrain.getHeights1D());
484 }
485 }
486 else
487 {
488 this.Terrain.setHeights1D(map);
489 }
490 }
491 catch (Exception e)
492 {
493 MainConsole.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
494 }
495 }
496 #endregion
497
498 #region Primitives Methods
499
500 /// <summary>
501 /// Sends prims to a client
502 /// </summary>
503 /// <param name="RemoteClient">Client to send to</param>
504 public void GetInitialPrims(ClientView RemoteClient)
505 {
506 try
507 {
508 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
509 {
510 if (Entities[UUID] is Primitive)
511 {
512 Primitive primitive = Entities[UUID] as Primitive;
513 primitive.UpdateClient(RemoteClient);
514 }
515 }
516 }
517 catch (Exception e)
518 {
519 MainConsole.Instance.Warn("World.cs: GetInitialPrims() - Failed with exception " + e.ToString());
520 }
521 }
522
523 /// <summary>
524 /// Loads the World's objects
525 /// </summary>
526 public void LoadPrimsFromStorage()
527 {
528 try
529 {
530 MainConsole.Instance.Notice("World.cs: LoadPrimsFromStorage() - Loading primitives");
531 this.localStorage.LoadPrimitives(this);
532 }
533 catch (Exception e)
534 {
535 MainConsole.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
536 }
537 }
538
539 /// <summary>
540 /// Loads a specific object from storage
541 /// </summary>
542 /// <param name="prim">The object to load</param>
543 public void PrimFromStorage(PrimData prim)
544 {
545 try
546 {
547 if (prim.LocalID >= this._primCount)
548 {
549 _primCount = prim.LocalID + 1;
550 }
551 MainConsole.Instance.Notice("World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
552 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
553 nPrim.CreateFromStorage(prim);
554 this.Entities.Add(nPrim.uuid, nPrim);
555 }
556 catch (Exception e)
557 {
558 MainConsole.Instance.Warn("World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
559 }
560 }
561
562 public void AddNewPrim(Packet addPacket, ClientView agentClient)
563 {
564 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentID);
565 }
566
567 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
568 {
569 try
570 {
571 MainConsole.Instance.Notice("World.cs: AddNewPrim() - Creating new prim");
572 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
573 prim.CreateFromPacket(addPacket, ownerID, this._primCount);
574 PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
575 PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
576 if (OpenSim.world.Avatar.PhysicsEngineFlying)
577 {
578 lock (this.LockPhysicsEngine)
579 {
580 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
581 }
582 }
583
584 this.Entities.Add(prim.uuid, prim);
585 this._primCount++;
586 }
587 catch (Exception e)
588 {
589 MainConsole.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
590 }
591 }
592
593 #endregion
594
595 #region Add/Remove Avatar Methods
596
597 public override Avatar AddViewerAgent(ClientView agentClient)
598 {
599 //register for events
600 agentClient.OnChatFromViewer += new ChatFromViewer(this.SimChat);
601 agentClient.OnRezObject += new RezObject(this.RezObject);
602 agentClient.OnModifyTerrain += new ModifyTerrain(this.ModifyTerrain);
603 agentClient.OnRegionHandShakeReply += new ClientView.GenericCall(this.SendLayerData);
604 agentClient.OnRequestWearables += new ClientView.GenericCall(this.GetInitialPrims);
605 agentClient.OnRequestAvatarsData += new ClientView.GenericCall(this.SendAvatarsToClient);
606 agentClient.OnLinkObjects += new LinkObjects(this.LinkObjects);
607 agentClient.OnAddPrim += new ClientView.GenericCall4(this.AddNewPrim);
608 agentClient.OnUpdatePrimShape += new ClientView.UpdateShape(this.UpdatePrimShape);
609
610 agentClient.OnObjectSelect += new ClientView.ObjectSelect(this.SelectPrim);
611 agentClient.OnUpdatePrimFlags += new ClientView.UpdatePrimFlags(this.UpdatePrimFlags);
612 agentClient.OnUpdatePrimTexture += new ClientView.UpdatePrimTexture(this.UpdatePrimTexture);
613 agentClient.OnUpdatePrimPosition += new ClientView.UpdatePrimVector(this.UpdatePrimPosition);
614 agentClient.OnUpdatePrimRotation += new ClientView.UpdatePrimRotation(this.UpdatePrimRotation);
615 agentClient.OnUpdatePrimScale += new ClientView.UpdatePrimVector(this.UpdatePrimScale);
616 agentClient.OnDeRezObject += new ClientView.GenericCall4(this.DeRezObject);
617
618 agentClient.OnParcelPropertiesRequest += new OpenSim.RegionServer.world.ParcelPropertiesRequest(ParcelPropertiesRequest);
619 agentClient.OnParcelDivideRequest += new OpenSim.RegionServer.world.ParcelDivideRequest(ParcelDivideRequest);
620 agentClient.OnParcelJoinRequest+=new OpenSim.RegionServer.world.ParcelJoinRequest(ParcelJoinRequest);
621 agentClient.OnParcelPropertiesUpdateRequest += new OpenSim.RegionServer.world.ParcelPropertiesUpdateRequest(ParcelPropertiesUpdateRequest);
622 Avatar newAvatar = null;
623 try
624 {
625 MainConsole.Instance.Notice("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
626 newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20);
627 MainConsole.Instance.Notice("World.cs:AddViewerAgent() - Adding new avatar to world");
628 MainConsole.Instance.Notice("World.cs:AddViewerAgent() - Starting RegionHandshake ");
629 newAvatar.SendRegionHandshake(this);
630 //if (!agentClient.m_child)
631 //{
632
633 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
634 lock (this.LockPhysicsEngine)
635 {
636 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
637 }
638 // }
639 lock (Entities)
640 {
641 if (!Entities.ContainsKey(agentClient.AgentID))
642 {
643 this.Entities.Add(agentClient.AgentID, newAvatar);
644 }
645 else
646 {
647 Entities[agentClient.AgentID] = newAvatar;
648 }
649 }
650 lock (Avatars)
651 {
652 if (Avatars.ContainsKey(agentClient.AgentID))
653 {
654 Avatars[agentClient.AgentID] = newAvatar;
655 }
656 else
657 {
658 this.Avatars.Add(agentClient.AgentID, newAvatar);
659 }
660 }
661 }
662 catch (Exception e)
663 {
664 MainConsole.Instance.Warn("World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
665 }
666 return newAvatar;
667 }
668
669
670
671
672
673
674
675 public override void RemoveViewerAgent(ClientView agentClient)
676 {
677 try
678 {
679 lock (Entities)
680 {
681 Entities.Remove(agentClient.AgentID);
682 }
683 lock (Avatars)
684 {
685 Avatars.Remove(agentClient.AgentID);
686 }
687 if (agentClient.ClientAvatar.PhysActor != null)
688 {
689 this.phyScene.RemoveAvatar(agentClient.ClientAvatar.PhysActor);
690 }
691 }
692 catch (Exception e)
693 {
694 MainConsole.Instance.Warn("World.cs: RemoveViewerAgent() - Failed with exception " + e.ToString());
695 }
696 }
697 #endregion
698
699 #region Request Avatars List Methods
700 //The idea is to have a group of method that return a list of avatars meeting some requirement
701 // ie it could be all Avatars within a certain range of the calling prim/avatar.
702
703 public List<Avatar> RequestAvatarList()
704 {
705 List<Avatar> result = new List<Avatar>();
706
707 foreach (Avatar avatar in Avatars.Values)
708 {
709 result.Add(avatar);
710 }
711
712 return result;
713 }
714 #endregion
715
716 #region ShutDown
717 /// <summary>
718 /// Tidy before shutdown
719 /// </summary>
720 public override void Close()
721 {
722 try
723 {
724 this.localStorage.ShutDown();
725 }
726 catch (Exception e)
727 {
728 OpenSim.Framework.Console.MainConsole.Instance.Error("World.cs: Close() - Failed with exception " + e.ToString());
729 }
730 }
731 #endregion
732
733 }
734}