aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs402
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs84
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs431
4 files changed, 489 insertions, 458 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 1401f6e..a32b625 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -377,19 +377,19 @@ namespace OpenSim
377 switch (command) 377 switch (command)
378 { 378 {
379 case "set-time": 379 case "set-time":
380 m_localScenes.SetTimePhase(Convert.ToInt32(cmdparams[0])); 380 m_localScenes.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0]));
381 break; 381 break;
382 382
383 case "force-update": 383 case "force-update":
384 Console.WriteLine("Updating all clients"); 384 Console.WriteLine("Updating all clients");
385 m_localScenes.ForceClientUpdate(); 385 m_localScenes.ForceCurrentSceneClientUpdate();
386 break; 386 break;
387 387
388 388
389 case "edit-scale": 389 case "edit-scale":
390 if (cmdparams.Length == 4) 390 if (cmdparams.Length == 4)
391 { 391 {
392 m_localScenes.HandleEditCommand(cmdparams); 392 m_localScenes.HandleEditCommandOnCurrentScene(cmdparams);
393 } 393 }
394 break; 394 break;
395 395
@@ -427,34 +427,34 @@ namespace OpenSim
427 case "save-xml": 427 case "save-xml":
428 if (cmdparams.Length > 0) 428 if (cmdparams.Length > 0)
429 { 429 {
430 m_localScenes.SavePrimsToXml(cmdparams[0]); 430 m_localScenes.SaveCurrentSceneToXml(cmdparams[0]);
431 } 431 }
432 else 432 else
433 { 433 {
434 m_localScenes.SavePrimsToXml(DEFAULT_PRIM_BACKUP_FILENAME); 434 m_localScenes.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
435 } 435 }
436 break; 436 break;
437 437
438 case "load-xml": 438 case "load-xml":
439 if (cmdparams.Length > 0) 439 if (cmdparams.Length > 0)
440 { 440 {
441 m_localScenes.LoadPrimsFromXml(cmdparams[0]); 441 m_localScenes.LoadCurrentSceneFromXml(cmdparams[0]);
442 } 442 }
443 else 443 else
444 { 444 {
445 m_localScenes.LoadPrimsFromXml(DEFAULT_PRIM_BACKUP_FILENAME); 445 m_localScenes.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME);
446 } 446 }
447 break; 447 break;
448 448
449 case "terrain": 449 case "terrain":
450 if (!m_localScenes.RunTerrainCmd(cmdparams, ref result)) 450 if (!m_localScenes.RunTerrainCmdOnCurrentScene(cmdparams, ref result))
451 { 451 {
452 m_log.Error(result); 452 m_log.Error(result);
453 } 453 }
454 break; 454 break;
455 455
456 case "script": 456 case "script":
457 m_localScenes.SendCommandToScripts(cmdparams); 457 m_localScenes.SendCommandToCurrentSceneScripts(cmdparams);
458 break; 458 break;
459 459
460 case "command-script": 460 case "command-script":
@@ -468,16 +468,16 @@ namespace OpenSim
468 // Treats each user as a super-admin when disabled 468 // Treats each user as a super-admin when disabled
469 bool permissions = Convert.ToBoolean(cmdparams[0]); 469 bool permissions = Convert.ToBoolean(cmdparams[0]);
470 470
471 m_localScenes.BypassPermissions(!permissions); 471 m_localScenes.SetBypassPermissionsOnCurrentScene(!permissions);
472 472
473 break; 473 break;
474 474
475 case "backup": 475 case "backup":
476 m_localScenes.Backup(); 476 m_localScenes.BackupCurrentScene();
477 break; 477 break;
478 478
479 case "alert": 479 case "alert":
480 m_localScenes.HandleAlertCommand(cmdparams); 480 m_localScenes.HandleAlertCommandOnCurrentScene(cmdparams);
481 break; 481 break;
482 482
483 case "create": 483 case "create":
@@ -497,7 +497,7 @@ namespace OpenSim
497 { 497 {
498 string regionName = this.CombineParams(cmdparams, 0); 498 string regionName = this.CombineParams(cmdparams, 0);
499 499
500 if (m_localScenes.TrySetCurrentRegion(regionName)) 500 if (m_localScenes.TrySetCurrentScene(regionName))
501 { 501 {
502 502
503 } 503 }
@@ -535,7 +535,7 @@ namespace OpenSim
535 int newDebug; 535 int newDebug;
536 if (int.TryParse(args[1], out newDebug)) 536 if (int.TryParse(args[1], out newDebug))
537 { 537 {
538 m_localScenes.DebugPacket(m_log, newDebug); 538 m_localScenes.SetDebugPacketOnCurrentScene(m_log, newDebug);
539 } 539 }
540 else 540 else
541 { 541 {
@@ -568,7 +568,7 @@ namespace OpenSim
568 case "users": 568 case "users":
569 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); 569 m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"));
570 570
571 List<ScenePresence> avatars = m_localScenes.GetAvatars(); 571 List<ScenePresence> avatars = m_localScenes.GetCurrentSceneAvatars();
572 572
573 foreach (ScenePresence avatar in avatars) 573 foreach (ScenePresence avatar in avatars)
574 { 574 {
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index 468a5b7..fb6c5d2 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -8,207 +8,207 @@ using OpenSim.Framework.Utilities;
8using OpenSim.Region.Environment.Interfaces; 8using OpenSim.Region.Environment.Interfaces;
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10 10
11namespace OpenSim.Region.Environment.Modules 11namespace OpenSim.Region.Environment.Modules
12{ 12{
13 public class ChatModule : IRegionModule, ISimChat 13 public class ChatModule : IRegionModule, ISimChat
14 { 14 {
15 private Scene m_scene; 15 private Scene m_scene;
16 16
17 private string m_server = "irc2.choopa.net"; 17 private string m_server = "irc2.choopa.net";
18 18
19 // private int m_port = 6668; 19 // private int m_port = 6668;
20 //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; 20 //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
21 private string m_nick = "OSimBot"; 21 private string m_nick = "OSimBot";
22 private string m_channel = "#opensim"; 22 private string m_channel = "#opensim";
23 23
24 // private NetworkStream m_stream; 24 // private NetworkStream m_stream;
25 private TcpClient m_irc; 25 private TcpClient m_irc;
26 private StreamWriter m_ircWriter; 26 private StreamWriter m_ircWriter;
27 private StreamReader m_ircReader; 27 private StreamReader m_ircReader;
28 28
29 // private Thread pingSender; 29 // private Thread pingSender;
30 // private Thread listener; 30 // private Thread listener;
31 31
32 private bool connected = false; 32 private bool connected = false;
33 33
34 public ChatModule() 34 public ChatModule()
35 { 35 {
36 m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); 36 m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
37 m_irc = null; 37 m_irc = null;
38 m_ircWriter = null; 38 m_ircWriter = null;
39 m_ircReader = null; 39 m_ircReader = null;
40 } 40 }
41 41
42 public void Initialise(Scene scene) 42 public void Initialise(Scene scene)
43 { 43 {
44 m_scene = scene; 44 m_scene = scene;
45 m_scene.EventManager.OnNewClient += NewClient; 45 m_scene.EventManager.OnNewClient += NewClient;
46 46
47 m_scene.RegisterModuleInterface<ISimChat>(this); 47 m_scene.RegisterModuleInterface<ISimChat>(this);
48 } 48 }
49 49
50 public void PostInitialise() 50 public void PostInitialise()
51 { 51 {
52 /* 52 /*
53 try 53 try
54 { 54 {
55 m_irc = new TcpClient(m_server, m_port); 55 m_irc = new TcpClient(m_server, m_port);
56 m_stream = m_irc.GetStream(); 56 m_stream = m_irc.GetStream();
57 m_ircReader = new StreamReader(m_stream); 57 m_ircReader = new StreamReader(m_stream);
58 m_ircWriter = new StreamWriter(m_stream); 58 m_ircWriter = new StreamWriter(m_stream);
59 59
60 pingSender = new Thread(new ThreadStart(this.PingRun)); 60 pingSender = new Thread(new ThreadStart(this.PingRun));
61 pingSender.Start(); 61 pingSender.Start();
62 62
63 listener = new Thread(new ThreadStart(this.ListenerRun)); 63 listener = new Thread(new ThreadStart(this.ListenerRun));
64 listener.Start(); 64 listener.Start();
65 65
66 m_ircWriter.WriteLine(m_user); 66 m_ircWriter.WriteLine(m_user);
67 m_ircWriter.Flush(); 67 m_ircWriter.Flush();
68 m_ircWriter.WriteLine("NICK " + m_nick); 68 m_ircWriter.WriteLine("NICK " + m_nick);
69 m_ircWriter.Flush(); 69 m_ircWriter.Flush();
70 m_ircWriter.WriteLine("JOIN " + m_channel); 70 m_ircWriter.WriteLine("JOIN " + m_channel);
71 m_ircWriter.Flush(); 71 m_ircWriter.Flush();
72 connected = true; 72 connected = true;
73 } 73 }
74 catch (Exception e) 74 catch (Exception e)
75 { 75 {
76 Console.WriteLine(e.ToString()); 76 Console.WriteLine(e.ToString());
77 } 77 }
78 */ 78 */
79 } 79 }
80 80
81 public void CloseDown() 81 public void CloseDown()
82 { 82 {
83 m_ircWriter.Close(); 83 m_ircWriter.Close();
84 m_ircReader.Close(); 84 m_ircReader.Close();
85 m_irc.Close(); 85 m_irc.Close();
86 } 86 }
87 87
88 public string GetName() 88 public string GetName()
89 { 89 {
90 return "ChatModule"; 90 return "ChatModule";
91 } 91 }
92 92
93 public bool IsSharedModule() 93 public bool IsSharedModule()
94 { 94 {
95 return false; 95 return false;
96 } 96 }
97 97
98 public void NewClient(IClientAPI client) 98 public void NewClient(IClientAPI client)
99 { 99 {
100 client.OnChatFromViewer += SimChat; 100 client.OnChatFromViewer += SimChat;
101 } 101 }
102 102
103 public void PingRun() 103 public void PingRun()
104 { 104 {
105 while (true) 105 while (true)
106 { 106 {
107 m_ircWriter.WriteLine("PING :" + m_server); 107 m_ircWriter.WriteLine("PING :" + m_server);
108 m_ircWriter.Flush(); 108 m_ircWriter.Flush();
109 Thread.Sleep(15000); 109 Thread.Sleep(15000);
110 } 110 }
111 } 111 }
112 112
113 public void ListenerRun() 113 public void ListenerRun()
114 { 114 {
115 string inputLine; 115 string inputLine;
116 LLVector3 pos = new LLVector3(128, 128, 20); 116 LLVector3 pos = new LLVector3(128, 128, 20);
117 while (true) 117 while (true)
118 { 118 {
119 while ((inputLine = m_ircReader.ReadLine()) != null) 119 while ((inputLine = m_ircReader.ReadLine()) != null)
120 { 120 {
121 Console.WriteLine(inputLine); 121 Console.WriteLine(inputLine);
122 if (inputLine.Contains(m_channel)) 122 if (inputLine.Contains(m_channel))
123 { 123 {
124 string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); 124 string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
125 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 125 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
126 { 126 {
127 presence.ControllingClient.SendChatMessage( 127 presence.ControllingClient.SendChatMessage(
128 Helpers.StringToField(mess), 255, pos, "IRC:", 128 Helpers.StringToField(mess), 255, pos, "IRC:",
129 LLUUID.Zero); 129 LLUUID.Zero);
130 }); 130 });
131 } 131 }
132 } 132 }
133 } 133 }
134 } 134 }
135 135
136 public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, 136 public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
137 LLUUID fromAgentID) 137 LLUUID fromAgentID)
138 { 138 {
139 ScenePresence avatar = null; 139 ScenePresence avatar = null;
140 avatar = m_scene.RequestAvatar(fromAgentID); 140 avatar = m_scene.RequestAvatar(fromAgentID);
141 if (avatar != null) 141 if (avatar != null)
142 { 142 {
143 fromPos = avatar.AbsolutePosition; 143 fromPos = avatar.AbsolutePosition;
144 fromName = avatar.Firstname + " " + avatar.Lastname; 144 fromName = avatar.Firstname + " " + avatar.Lastname;
145 avatar = null; 145 avatar = null;
146 } 146 }
147 147
148 if (connected) 148 if (connected)
149 { 149 {
150 m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + 150 m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " +
151 Util.FieldToString(message)); 151 Util.FieldToString(message));
152 m_ircWriter.Flush(); 152 m_ircWriter.Flush();
153 } 153 }
154 154
155 if (channel == 0) 155 if (channel == 0)
156 { 156 {
157 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 157 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
158 { 158 {
159 int dis = -1000; 159 int dis = -1000;
160 160
161 //err ??? the following code seems to be request a scenePresence when it already has a ref to it 161 //err ??? the following code seems to be request a scenePresence when it already has a ref to it
162 avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); 162 avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId);
163 if (avatar != null) 163 if (avatar != null)
164 { 164 {
165 dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); 165 dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
166 } 166 }
167 167
168 switch (type) 168 switch (type)
169 { 169 {
170 case 0: // Whisper 170 case 0: // Whisper
171 if ((dis < 10) && (dis > -10)) 171 if ((dis < 10) && (dis > -10))
172 { 172 {
173 //should change so the message is sent through the avatar rather than direct to the ClientView 173 //should change so the message is sent through the avatar rather than direct to the ClientView
174 presence.ControllingClient.SendChatMessage(message, 174 presence.ControllingClient.SendChatMessage(message,
175 type, 175 type,
176 fromPos, 176 fromPos,
177 fromName, 177 fromName,
178 fromAgentID); 178 fromAgentID);
179 } 179 }
180 break; 180 break;
181 case 1: // Say 181 case 1: // Say
182 if ((dis < 30) && (dis > -30)) 182 if ((dis < 30) && (dis > -30))
183 { 183 {
184 //Console.WriteLine("sending chat"); 184 //Console.WriteLine("sending chat");
185 presence.ControllingClient.SendChatMessage(message, 185 presence.ControllingClient.SendChatMessage(message,
186 type, 186 type,
187 fromPos, 187 fromPos,
188 fromName, 188 fromName,
189 fromAgentID); 189 fromAgentID);
190 } 190 }
191 break; 191 break;
192 case 2: // Shout 192 case 2: // Shout
193 if ((dis < 100) && (dis > -100)) 193 if ((dis < 100) && (dis > -100))
194 { 194 {
195 presence.ControllingClient.SendChatMessage(message, 195 presence.ControllingClient.SendChatMessage(message,
196 type, 196 type,
197 fromPos, 197 fromPos,
198 fromName, 198 fromName,
199 fromAgentID); 199 fromAgentID);
200 } 200 }
201 break; 201 break;
202 202
203 case 0xff: // Broadcast 203 case 0xff: // Broadcast
204 presence.ControllingClient.SendChatMessage(message, type, 204 presence.ControllingClient.SendChatMessage(message, type,
205 fromPos, 205 fromPos,
206 fromName, 206 fromName,
207 fromAgentID); 207 fromAgentID);
208 break; 208 break;
209 } 209 }
210 }); 210 });
211 } 211 }
212 } 212 }
213 } 213 }
214} \ No newline at end of file 214} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 3a45e23..874bb41 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -48,7 +48,7 @@ using OpenSim.Region.Environment.Scenes.Scripting;
48using OpenSim.Region.Environment.Types; 48using OpenSim.Region.Environment.Types;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.Physics.Manager;
50using OpenSim.Region.Terrain; 50using OpenSim.Region.Terrain;
51using Timer=System.Timers.Timer; 51using Timer = System.Timers.Timer;
52 52
53namespace OpenSim.Region.Environment.Scenes 53namespace OpenSim.Region.Environment.Scenes
54{ 54{
@@ -195,7 +195,7 @@ namespace OpenSim.Region.Environment.Scenes
195 Prims = new Dictionary<LLUUID, SceneObjectGroup>(); 195 Prims = new Dictionary<LLUUID, SceneObjectGroup>();
196 196
197 MainLog.Instance.Verbose("Creating LandMap"); 197 MainLog.Instance.Verbose("Creating LandMap");
198 Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); 198 Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
199 199
200 ScenePresence.LoadAnims(); 200 ScenePresence.LoadAnims();
201 201
@@ -254,7 +254,7 @@ namespace OpenSim.Region.Environment.Scenes
254 if (phyScene.IsThreaded) 254 if (phyScene.IsThreaded)
255 { 255 {
256 phyScene.GetResults(); 256 phyScene.GetResults();
257 /// no engines implement this, and what does it have to do with threading? possible DEAD CODE 257 /// no engines implement this, and what does it have to do with threading? possible DEAD CODE
258 } 258 }
259 259
260 List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values); 260 List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
@@ -313,7 +313,7 @@ namespace OpenSim.Region.Environment.Scenes
313 { 313 {
314 for (int y = 0; y < 16; y++) 314 for (int y = 0; y < 16; y++)
315 { 315 {
316 if (Terrain.Tainted(x*16, y*16)) 316 if (Terrain.Tainted(x * 16, y * 16))
317 { 317 {
318 SendLayerData(x, y, presence.ControllingClient, 318 SendLayerData(x, y, presence.ControllingClient,
319 terData); 319 terData);
@@ -526,7 +526,7 @@ namespace OpenSim.Region.Environment.Scenes
526 { 526 {
527 AddEntityFromStorage(prim); 527 AddEntityFromStorage(prim);
528 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 528 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
529 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 529 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
530 rootPart.PhysActor = phyScene.AddPrim( 530 rootPart.PhysActor = phyScene.AddPrim(
531 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 531 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
532 rootPart.AbsolutePosition.Z), 532 rootPart.AbsolutePosition.Z),
@@ -570,10 +570,10 @@ namespace OpenSim.Region.Environment.Scenes
570 // if grass or tree, make phantom 570 // if grass or tree, make phantom
571 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) 571 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
572 { 572 {
573 rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom; 573 rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
574 } 574 }
575 // if not phantom, add to physics 575 // if not phantom, add to physics
576 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 576 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
577 rootPart.PhysActor = 577 rootPart.PhysActor =
578 phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z), 578 phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z),
579 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), 579 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
@@ -587,9 +587,9 @@ namespace OpenSim.Region.Environment.Scenes
587 { 587 {
588 if (obj is SceneObjectGroup) 588 if (obj is SceneObjectGroup)
589 { 589 {
590 if (((SceneObjectGroup) obj).LocalId == localID) 590 if (((SceneObjectGroup)obj).LocalId == localID)
591 { 591 {
592 RemoveEntity((SceneObjectGroup) obj); 592 RemoveEntity((SceneObjectGroup)obj);
593 return; 593 return;
594 } 594 }
595 } 595 }
@@ -657,7 +657,7 @@ namespace OpenSim.Region.Environment.Scenes
657 AddEntity(obj); 657 AddEntity(obj);
658 658
659 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 659 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
660 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 660 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
661 rootPart.PhysActor = phyScene.AddPrim( 661 rootPart.PhysActor = phyScene.AddPrim(
662 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 662 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
663 rootPart.AbsolutePosition.Z), 663 rootPart.AbsolutePosition.Z),
@@ -683,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes
683 { 683 {
684 if (ent is SceneObjectGroup) 684 if (ent is SceneObjectGroup)
685 { 685 {
686 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); 686 stream.WriteLine(((SceneObjectGroup)ent).ToXmlString());
687 primCount++; 687 primCount++;
688 } 688 }
689 } 689 }
@@ -706,9 +706,9 @@ namespace OpenSim.Region.Environment.Scenes
706 { 706 {
707 SubscribeToClientEvents(client); 707 SubscribeToClientEvents(client);
708 m_estateManager.sendRegionHandshake(client); 708 m_estateManager.sendRegionHandshake(client);
709 709
710 CreateAndAddScenePresence(client, child); 710 CreateAndAddScenePresence(client, child);
711 711
712 m_LandManager.sendParcelOverlay(client); 712 m_LandManager.sendParcelOverlay(client);
713 commsManager.UserProfiles.AddNewUser(client.AgentId); 713 commsManager.UserProfiles.AddNewUser(client.AgentId);
714 commsManager.TransactionsManager.AddUser(client.AgentId); 714 commsManager.TransactionsManager.AddUser(client.AgentId);
@@ -793,7 +793,7 @@ namespace OpenSim.Region.Environment.Scenes
793 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new root agent."); 793 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new root agent.");
794 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Adding Physical agent."); 794 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Adding Physical agent.");
795 795
796 newAvatar.AddToPhysicalScene( ); 796 newAvatar.AddToPhysicalScene();
797 } 797 }
798 798
799 lock (Entities) 799 lock (Entities)
@@ -835,14 +835,14 @@ namespace OpenSim.Region.Environment.Scenes
835 835
836 ForEachScenePresence( 836 ForEachScenePresence(
837 delegate(ScenePresence presence) 837 delegate(ScenePresence presence)
838 {
839 presence.CoarseLocationChange(avatar);
840 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
841 if (presence.PhysActor != null)
838 { 842 {
839 presence.CoarseLocationChange(avatar); 843 phyScene.RemoveAvatar(presence.PhysActor);
840 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); 844 }
841 if (presence.PhysActor != null) 845 });
842 {
843 phyScene.RemoveAvatar(presence.PhysActor);
844 }
845 });
846 846
847 lock (Avatars) 847 lock (Avatars)
848 { 848 {
@@ -968,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes
968 if (ent is SceneObjectGroup) 968 if (ent is SceneObjectGroup)
969 { 969 {
970 // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); 970 // ((SceneObjectGroup)ent).SendFullUpdateToClient(client);
971 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); 971 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
972 } 972 }
973 } 973 }
974 } 974 }
@@ -1157,17 +1157,17 @@ namespace OpenSim.Region.Environment.Scenes
1157 1157
1158 public void RegisterModuleInterface<M>(M mod) 1158 public void RegisterModuleInterface<M>(M mod)
1159 { 1159 {
1160 if (!ModuleInterfaces.ContainsKey(typeof (M))) 1160 if (!ModuleInterfaces.ContainsKey(typeof(M)))
1161 { 1161 {
1162 ModuleInterfaces.Add(typeof (M), mod); 1162 ModuleInterfaces.Add(typeof(M), mod);
1163 } 1163 }
1164 } 1164 }
1165 1165
1166 public T RequestModuleInterface<T>() 1166 public T RequestModuleInterface<T>()
1167 { 1167 {
1168 if (ModuleInterfaces.ContainsKey(typeof (T))) 1168 if (ModuleInterfaces.ContainsKey(typeof(T)))
1169 { 1169 {
1170 return (T) ModuleInterfaces[typeof (T)]; 1170 return (T)ModuleInterfaces[typeof(T)];
1171 } 1171 }
1172 else 1172 else
1173 { 1173 {
@@ -1257,7 +1257,7 @@ namespace OpenSim.Region.Environment.Scenes
1257 { 1257 {
1258 if (ent is SceneObjectGroup) 1258 if (ent is SceneObjectGroup)
1259 { 1259 {
1260 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); 1260 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
1261 } 1261 }
1262 } 1262 }
1263 } 1263 }
@@ -1269,7 +1269,7 @@ namespace OpenSim.Region.Environment.Scenes
1269 { 1269 {
1270 if (ent is SceneObjectGroup) 1270 if (ent is SceneObjectGroup)
1271 { 1271 {
1272 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); 1272 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
1273 if (part != null) 1273 if (part != null)
1274 { 1274 {
1275 if (part.Name == cmmdparams[0]) 1275 if (part.Name == cmmdparams[0])
@@ -1357,10 +1357,10 @@ namespace OpenSim.Region.Environment.Scenes
1357 { 1357 {
1358 if (ent is SceneObjectGroup) 1358 if (ent is SceneObjectGroup)
1359 { 1359 {
1360 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); 1360 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
1361 if (hasPrim != false) 1361 if (hasPrim != false)
1362 { 1362 {
1363 return ((SceneObjectGroup) ent).GetPartsFullID(localID); 1363 return ((SceneObjectGroup)ent).GetPartsFullID(localID);
1364 } 1364 }
1365 } 1365 }
1366 } 1366 }
@@ -1374,10 +1374,10 @@ namespace OpenSim.Region.Environment.Scenes
1374 { 1374 {
1375 if (ent is SceneObjectGroup) 1375 if (ent is SceneObjectGroup)
1376 { 1376 {
1377 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); 1377 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
1378 if (hasPrim != false) 1378 if (hasPrim != false)
1379 { 1379 {
1380 return ((SceneObjectGroup) ent).GetChildPart(localID); 1380 return ((SceneObjectGroup)ent).GetChildPart(localID);
1381 } 1381 }
1382 } 1382 }
1383 } 1383 }
@@ -1391,14 +1391,30 @@ namespace OpenSim.Region.Environment.Scenes
1391 { 1391 {
1392 if (ent is SceneObjectGroup) 1392 if (ent is SceneObjectGroup)
1393 { 1393 {
1394 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID); 1394 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID);
1395 if (hasPrim != false) 1395 if (hasPrim != false)
1396 { 1396 {
1397 return ((SceneObjectGroup) ent).GetChildPart(fullID); 1397 return ((SceneObjectGroup)ent).GetChildPart(fullID);
1398 } 1398 }
1399 } 1399 }
1400 } 1400 }
1401 return null; 1401 return null;
1402 } 1402 }
1403
1404 internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
1405 {
1406 ScenePresence presence;
1407 if (Avatars.TryGetValue(avatarId, out presence))
1408 {
1409 if (!presence.childAgent)
1410 {
1411 avatar = presence;
1412 return true;
1413 }
1414 }
1415
1416 avatar = null;
1417 return false;
1418 }
1403 } 1419 }
1404} \ No newline at end of file 1420} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index effd4b2..0670fc7 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -2,215 +2,230 @@ using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using OpenSim.Framework.Console; 3using OpenSim.Framework.Console;
4using OpenSim.Framework.Types; 4using OpenSim.Framework.Types;
5using libsecondlife;
5 6
6namespace OpenSim.Region.Environment.Scenes 7namespace OpenSim.Region.Environment.Scenes
7{ 8{
8 public class SceneManager 9 public class SceneManager
9 { 10 {
10 private readonly List<Scene> m_localScenes; 11 private readonly List<Scene> m_localScenes;
11 private Scene m_currentScene = null; 12 private Scene m_currentScene = null;
12 13
13 public Scene CurrentScene 14 public Scene CurrentScene
14 { 15 {
15 get { return m_currentScene; } 16 get { return m_currentScene; }
16 } 17 }
17 18
18 private Scene CurrentOrFirstScene 19 public Scene CurrentOrFirstScene
19 { 20 {
20 get 21 get
21 { 22 {
22 if (m_currentScene == null) 23 if (m_currentScene == null)
23 { 24 {
24 return m_localScenes[0]; 25 return m_localScenes[0];
25 } 26 }
26 else 27 else
27 { 28 {
28 return m_currentScene; 29 return m_currentScene;
29 } 30 }
30 } 31 }
31 } 32 }
32 33
33 public SceneManager() 34 public SceneManager()
34 { 35 {
35 m_localScenes = new List<Scene>(); 36 m_localScenes = new List<Scene>();
36 } 37 }
37 38
38 public void Close() 39 public void Close()
39 { 40 {
40 for (int i = 0; i < m_localScenes.Count; i++) 41 for (int i = 0; i < m_localScenes.Count; i++)
41 { 42 {
42 m_localScenes[i].Close(); 43 m_localScenes[i].Close();
43 } 44 }
44 } 45 }
45 46
46 public void Add(Scene scene) 47 public void Add(Scene scene)
47 { 48 {
48 m_localScenes.Add(scene); 49 m_localScenes.Add(scene);
49 } 50 }
50 51
51 public void SavePrimsToXml(string filename) 52 public void SaveCurrentSceneToXml(string filename)
52 { 53 {
53 CurrentOrFirstScene.SavePrimsToXml(filename); 54 CurrentOrFirstScene.SavePrimsToXml(filename);
54 } 55 }
55 56
56 public void LoadPrimsFromXml(string filename) 57 public void LoadCurrentSceneFromXml(string filename)
57 { 58 {
58 CurrentOrFirstScene.LoadPrimsFromXml(filename); 59 CurrentOrFirstScene.LoadPrimsFromXml(filename);
59 } 60 }
60 61
61 public bool RunTerrainCmd(string[] cmdparams, ref string result) 62 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
62 { 63 {
63 if (m_currentScene == null) 64 if (m_currentScene == null)
64 { 65 {
65 bool success = true; 66 bool success = true;
66 foreach (Scene scene in m_localScenes) 67 foreach (Scene scene in m_localScenes)
67 { 68 {
68 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) 69 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
69 { 70 {
70 success = false; 71 success = false;
71 } 72 }
72 } 73 }
73 74
74 return success; 75 return success;
75 } 76 }
76 else 77 else
77 { 78 {
78 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); 79 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
79 } 80 }
80 } 81 }
81 82
82 public void SendCommandToScripts(string[] cmdparams) 83 public void SendCommandToCurrentSceneScripts(string[] cmdparams)
83 { 84 {
84 ForEach(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); }); 85 ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); });
85 } 86 }
86 87
87 public void BypassPermissions(bool bypassPermissions) 88 public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
88 { 89 {
89 ForEach(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; }); 90 ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
90 } 91 }
91 92
92 private void ForEach(Action<Scene> func) 93 private void ForEachCurrentScene(Action<Scene> func)
93 { 94 {
94 if (m_currentScene == null) 95 if (m_currentScene == null)
95 { 96 {
96 m_localScenes.ForEach(func); 97 m_localScenes.ForEach(func);
97 } 98 }
98 else 99 else
99 { 100 {
100 func(m_currentScene); 101 func(m_currentScene);
101 } 102 }
102 } 103 }
103 104
104 public void Backup() 105 public void BackupCurrentScene()
105 { 106 {
106 ForEach(delegate(Scene scene) { scene.Backup(); }); 107 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
107 } 108 }
108 109
109 public void HandleAlertCommand(string[] cmdparams) 110 public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
110 { 111 {
111 ForEach(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); 112 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
112 } 113 }
113 114
114 public bool TrySetCurrentRegion(string regionName) 115 public bool TrySetCurrentScene(string regionName)
115 { 116 {
116 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) 117 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
117 { 118 {
118 m_currentScene = null; 119 m_currentScene = null;
119 return true; 120 return true;
120 } 121 }
121 else 122 else
122 { 123 {
123 Console.WriteLine("Searching for Region: '" + regionName + "'"); 124 Console.WriteLine("Searching for Region: '" + regionName + "'");
124 125
125 foreach (Scene scene in m_localScenes) 126 foreach (Scene scene in m_localScenes)
126 { 127 {
127 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) 128 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
128 { 129 {
129 m_currentScene = scene; 130 m_currentScene = scene;
130 return true; 131 return true;
131 } 132 }
132 } 133 }
133 134
134 return false; 135 return false;
135 } 136 }
136 } 137 }
137 138
138 public void DebugPacket(LogBase log, int newDebug) 139 public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
139 { 140 {
140 ForEach(delegate(Scene scene) 141 ForEachCurrentScene(delegate(Scene scene)
141 { 142 {
142 foreach (EntityBase entity in scene.Entities.Values) 143 foreach (EntityBase entity in scene.Entities.Values)
143 { 144 {
144 if (entity is ScenePresence) 145 if (entity is ScenePresence)
145 { 146 {
146 ScenePresence scenePrescence = entity as ScenePresence; 147 ScenePresence scenePrescence = entity as ScenePresence;
147 if (!scenePrescence.childAgent) 148 if (!scenePrescence.childAgent)
148 { 149 {
149 log.Error(String.Format("Packet debug for {0} {1} set to {2}", 150 log.Error(String.Format("Packet debug for {0} {1} set to {2}",
150 scenePrescence.Firstname, scenePrescence.Lastname, 151 scenePrescence.Firstname, scenePrescence.Lastname,
151 newDebug)); 152 newDebug));
152 153
153 scenePrescence.ControllingClient.SetDebug(newDebug); 154 scenePrescence.ControllingClient.SetDebug(newDebug);
154 } 155 }
155 } 156 }
156 } 157 }
157 }); 158 });
158 } 159 }
159 160
160 public List<ScenePresence> GetAvatars() 161 public List<ScenePresence> GetCurrentSceneAvatars()
161 { 162 {
162 List<ScenePresence> avatars = new List<ScenePresence>(); 163 List<ScenePresence> avatars = new List<ScenePresence>();
163 164
164 ForEach(delegate(Scene scene) 165 ForEachCurrentScene(delegate(Scene scene)
165 { 166 {
166 foreach (EntityBase entity in scene.Entities.Values) 167 foreach (EntityBase entity in scene.Entities.Values)
167 { 168 {
168 if (entity is ScenePresence) 169 if (entity is ScenePresence)
169 { 170 {
170 ScenePresence scenePrescence = entity as ScenePresence; 171 ScenePresence scenePrescence = entity as ScenePresence;
171 if (!scenePrescence.childAgent) 172 if (!scenePrescence.childAgent)
172 { 173 {
173 avatars.Add(scenePrescence); 174 avatars.Add(scenePrescence);
174 } 175 }
175 } 176 }
176 } 177 }
177 }); 178 });
178 179
179 return avatars; 180 return avatars;
180 } 181 }
181 182
182 public RegionInfo GetRegionInfo(ulong regionHandle) 183 public RegionInfo GetRegionInfo(ulong regionHandle)
183 { 184 {
184 foreach (Scene scene in m_localScenes) 185 foreach (Scene scene in m_localScenes)
185 { 186 {
186 if (scene.RegionInfo.RegionHandle == regionHandle) 187 if (scene.RegionInfo.RegionHandle == regionHandle)
187 { 188 {
188 return scene.RegionInfo; 189 return scene.RegionInfo;
189 } 190 }
190 } 191 }
191 192
192 return null; 193 return null;
193 } 194 }
194 195
195 public void SetTimePhase(int timePhase) 196 public void SetCurrentSceneTimePhase(int timePhase)
196 { 197 {
197 ForEach(delegate(Scene scene) 198 ForEachCurrentScene(delegate(Scene scene)
198 { 199 {
199 scene.SetTimePhase( 200 scene.SetTimePhase(
200 timePhase) 201 timePhase)
201 ; 202 ;
202 }); 203 });
203 } 204 }
204 205
205 206
206 public void ForceClientUpdate() 207 public void ForceCurrentSceneClientUpdate()
207 { 208 {
208 ForEach(delegate(Scene scene) { scene.ForceClientUpdate(); }); 209 ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
209 } 210 }
210 211
211 public void HandleEditCommand(string[] cmdparams) 212 public void HandleEditCommandOnCurrentScene(string[] cmdparams)
212 { 213 {
213 ForEach(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 214 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
214 } 215 }
215 } 216
217 public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
218 {
219 foreach (Scene scene in m_localScenes)
220 {
221 if( scene.TryGetAvatar( avatarId, out avatar ))
222 {
223 return true;
224 }
225 }
226
227 avatar = null;
228 return false;
229 }
230 }
216} \ No newline at end of file 231} \ No newline at end of file