diff options
Merge branch 'master' into bulletsim
Conflicts:
OpenSim/Region/Framework/Scenes/SceneManager.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneManager.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 226 |
1 files changed, 139 insertions, 87 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 97ee844..7fada4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -53,12 +53,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
53 | get { return m_instance; } | 53 | get { return m_instance; } |
54 | } | 54 | } |
55 | 55 | ||
56 | private readonly List<Scene> m_localScenes; | 56 | private readonly List<Scene> m_localScenes = new List<Scene>(); |
57 | private Scene m_currentScene = null; | 57 | private Scene m_currentScene = null; |
58 | 58 | ||
59 | public List<Scene> Scenes | 59 | public List<Scene> Scenes |
60 | { | 60 | { |
61 | get { return m_localScenes; } | 61 | get { return new List<Scene>(m_localScenes); } |
62 | } | 62 | } |
63 | 63 | ||
64 | public Scene CurrentScene | 64 | public Scene CurrentScene |
@@ -72,13 +72,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
72 | { | 72 | { |
73 | if (m_currentScene == null) | 73 | if (m_currentScene == null) |
74 | { | 74 | { |
75 | if (m_localScenes.Count > 0) | 75 | lock (m_localScenes) |
76 | { | 76 | { |
77 | return m_localScenes[0]; | 77 | if (m_localScenes.Count > 0) |
78 | } | 78 | return m_localScenes[0]; |
79 | else | 79 | else |
80 | { | 80 | return null; |
81 | return null; | ||
82 | } | 81 | } |
83 | } | 82 | } |
84 | else | 83 | else |
@@ -98,17 +97,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
98 | { | 97 | { |
99 | // collect known shared modules in sharedModules | 98 | // collect known shared modules in sharedModules |
100 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); | 99 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); |
101 | for (int i = 0; i < m_localScenes.Count; i++) | 100 | |
101 | lock (m_localScenes) | ||
102 | { | 102 | { |
103 | // extract known shared modules from scene | 103 | for (int i = 0; i < m_localScenes.Count; i++) |
104 | foreach (string k in m_localScenes[i].Modules.Keys) | ||
105 | { | 104 | { |
106 | if (m_localScenes[i].Modules[k].IsSharedModule && | 105 | // extract known shared modules from scene |
107 | !sharedModules.ContainsKey(k)) | 106 | foreach (string k in m_localScenes[i].Modules.Keys) |
108 | sharedModules[k] = m_localScenes[i].Modules[k]; | 107 | { |
108 | if (m_localScenes[i].Modules[k].IsSharedModule && | ||
109 | !sharedModules.ContainsKey(k)) | ||
110 | sharedModules[k] = m_localScenes[i].Modules[k]; | ||
111 | } | ||
112 | // close scene/region | ||
113 | m_localScenes[i].Close(); | ||
109 | } | 114 | } |
110 | // close scene/region | ||
111 | m_localScenes[i].Close(); | ||
112 | } | 115 | } |
113 | 116 | ||
114 | // all regions/scenes are now closed, we can now safely | 117 | // all regions/scenes are now closed, we can now safely |
@@ -121,13 +124,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | 124 | ||
122 | public void Close(Scene cscene) | 125 | public void Close(Scene cscene) |
123 | { | 126 | { |
124 | if (m_localScenes.Contains(cscene)) | 127 | lock (m_localScenes) |
125 | { | 128 | { |
126 | for (int i = 0; i < m_localScenes.Count; i++) | 129 | if (m_localScenes.Contains(cscene)) |
127 | { | 130 | { |
128 | if (m_localScenes[i].Equals(cscene)) | 131 | for (int i = 0; i < m_localScenes.Count; i++) |
129 | { | 132 | { |
130 | m_localScenes[i].Close(); | 133 | if (m_localScenes[i].Equals(cscene)) |
134 | { | ||
135 | m_localScenes[i].Close(); | ||
136 | } | ||
131 | } | 137 | } |
132 | } | 138 | } |
133 | } | 139 | } |
@@ -136,27 +142,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
136 | public void Add(Scene scene) | 142 | public void Add(Scene scene) |
137 | { | 143 | { |
138 | scene.OnRestart += HandleRestart; | 144 | scene.OnRestart += HandleRestart; |
139 | m_localScenes.Add(scene); | 145 | |
146 | lock (m_localScenes) | ||
147 | m_localScenes.Add(scene); | ||
140 | } | 148 | } |
141 | 149 | ||
142 | public void HandleRestart(RegionInfo rdata) | 150 | public void HandleRestart(RegionInfo rdata) |
143 | { | 151 | { |
144 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 152 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); |
145 | int RegionSceneElement = -1; | 153 | int RegionSceneElement = -1; |
146 | for (int i = 0; i < m_localScenes.Count; i++) | 154 | |
155 | lock (m_localScenes) | ||
147 | { | 156 | { |
148 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | 157 | for (int i = 0; i < m_localScenes.Count; i++) |
149 | { | 158 | { |
150 | RegionSceneElement = i; | 159 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) |
160 | { | ||
161 | RegionSceneElement = i; | ||
162 | } | ||
151 | } | 163 | } |
152 | } | ||
153 | 164 | ||
154 | // Now we make sure the region is no longer known about by the SceneManager | 165 | // Now we make sure the region is no longer known about by the SceneManager |
155 | // Prevents duplicates. | 166 | // Prevents duplicates. |
156 | 167 | ||
157 | if (RegionSceneElement >= 0) | 168 | if (RegionSceneElement >= 0) |
158 | { | 169 | { |
159 | m_localScenes.RemoveAt(RegionSceneElement); | 170 | m_localScenes.RemoveAt(RegionSceneElement); |
171 | } | ||
160 | } | 172 | } |
161 | 173 | ||
162 | // Send signal to main that we're restarting this sim. | 174 | // Send signal to main that we're restarting this sim. |
@@ -167,28 +179,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | { | 179 | { |
168 | RegionInfo Result = null; | 180 | RegionInfo Result = null; |
169 | 181 | ||
170 | for (int i = 0; i < m_localScenes.Count; i++) | 182 | lock (m_localScenes) |
171 | { | ||
172 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
173 | { | ||
174 | // Inform other regions to tell their avatar about me | ||
175 | Result = m_localScenes[i].RegionInfo; | ||
176 | } | ||
177 | } | ||
178 | if (Result != null) | ||
179 | { | 183 | { |
180 | for (int i = 0; i < m_localScenes.Count; i++) | 184 | for (int i = 0; i < m_localScenes.Count; i++) |
181 | { | 185 | { |
182 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 186 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) |
183 | { | 187 | { |
184 | // Inform other regions to tell their avatar about me | 188 | // Inform other regions to tell their avatar about me |
185 | //m_localScenes[i].OtherRegionUp(Result); | 189 | Result = m_localScenes[i].RegionInfo; |
186 | } | 190 | } |
187 | } | 191 | } |
188 | } | 192 | |
189 | else | 193 | if (Result != null) |
190 | { | 194 | { |
191 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 195 | for (int i = 0; i < m_localScenes.Count; i++) |
196 | { | ||
197 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | ||
198 | { | ||
199 | // Inform other regions to tell their avatar about me | ||
200 | //m_localScenes[i].OtherRegionUp(Result); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | ||
207 | } | ||
192 | } | 208 | } |
193 | } | 209 | } |
194 | 210 | ||
@@ -292,7 +308,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | { | 308 | { |
293 | if (m_currentScene == null) | 309 | if (m_currentScene == null) |
294 | { | 310 | { |
295 | m_localScenes.ForEach(func); | 311 | lock (m_localScenes) |
312 | m_localScenes.ForEach(func); | ||
296 | } | 313 | } |
297 | else | 314 | else |
298 | { | 315 | { |
@@ -321,12 +338,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | } | 338 | } |
322 | else | 339 | else |
323 | { | 340 | { |
324 | foreach (Scene scene in m_localScenes) | 341 | lock (m_localScenes) |
325 | { | 342 | { |
326 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | 343 | foreach (Scene scene in m_localScenes) |
327 | { | 344 | { |
328 | m_currentScene = scene; | 345 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) |
329 | return true; | 346 | { |
347 | m_currentScene = scene; | ||
348 | return true; | ||
349 | } | ||
330 | } | 350 | } |
331 | } | 351 | } |
332 | 352 | ||
@@ -338,12 +358,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | { | 358 | { |
339 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 359 | m_log.Debug("Searching for Region: '" + regionID + "'"); |
340 | 360 | ||
341 | foreach (Scene scene in m_localScenes) | 361 | lock (m_localScenes) |
342 | { | 362 | { |
343 | if (scene.RegionInfo.RegionID == regionID) | 363 | foreach (Scene scene in m_localScenes) |
344 | { | 364 | { |
345 | m_currentScene = scene; | 365 | if (scene.RegionInfo.RegionID == regionID) |
346 | return true; | 366 | { |
367 | m_currentScene = scene; | ||
368 | return true; | ||
369 | } | ||
347 | } | 370 | } |
348 | } | 371 | } |
349 | 372 | ||
@@ -352,26 +375,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
352 | 375 | ||
353 | public bool TryGetScene(string regionName, out Scene scene) | 376 | public bool TryGetScene(string regionName, out Scene scene) |
354 | { | 377 | { |
355 | foreach (Scene mscene in m_localScenes) | 378 | lock (m_localScenes) |
356 | { | 379 | { |
357 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | 380 | foreach (Scene mscene in m_localScenes) |
358 | { | 381 | { |
359 | scene = mscene; | 382 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) |
360 | return true; | 383 | { |
384 | scene = mscene; | ||
385 | return true; | ||
386 | } | ||
361 | } | 387 | } |
362 | } | 388 | } |
389 | |||
363 | scene = null; | 390 | scene = null; |
364 | return false; | 391 | return false; |
365 | } | 392 | } |
366 | 393 | ||
367 | public bool TryGetScene(UUID regionID, out Scene scene) | 394 | public bool TryGetScene(UUID regionID, out Scene scene) |
368 | { | 395 | { |
369 | foreach (Scene mscene in m_localScenes) | 396 | lock (m_localScenes) |
370 | { | 397 | { |
371 | if (mscene.RegionInfo.RegionID == regionID) | 398 | foreach (Scene mscene in m_localScenes) |
372 | { | 399 | { |
373 | scene = mscene; | 400 | if (mscene.RegionInfo.RegionID == regionID) |
374 | return true; | 401 | { |
402 | scene = mscene; | ||
403 | return true; | ||
404 | } | ||
375 | } | 405 | } |
376 | } | 406 | } |
377 | 407 | ||
@@ -381,13 +411,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
381 | 411 | ||
382 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 412 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
383 | { | 413 | { |
384 | foreach (Scene mscene in m_localScenes) | 414 | lock (m_localScenes) |
385 | { | 415 | { |
386 | if (mscene.RegionInfo.RegionLocX == locX && | 416 | foreach (Scene mscene in m_localScenes) |
387 | mscene.RegionInfo.RegionLocY == locY) | ||
388 | { | 417 | { |
389 | scene = mscene; | 418 | if (mscene.RegionInfo.RegionLocX == locX && |
390 | return true; | 419 | mscene.RegionInfo.RegionLocY == locY) |
420 | { | ||
421 | scene = mscene; | ||
422 | return true; | ||
423 | } | ||
391 | } | 424 | } |
392 | } | 425 | } |
393 | 426 | ||
@@ -397,13 +430,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
397 | 430 | ||
398 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 431 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
399 | { | 432 | { |
400 | foreach (Scene mscene in m_localScenes) | 433 | lock (m_localScenes) |
401 | { | 434 | { |
402 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 435 | foreach (Scene mscene in m_localScenes) |
403 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
404 | { | 436 | { |
405 | scene = mscene; | 437 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
406 | return true; | 438 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) |
439 | { | ||
440 | scene = mscene; | ||
441 | return true; | ||
442 | } | ||
407 | } | 443 | } |
408 | } | 444 | } |
409 | 445 | ||
@@ -472,11 +508,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
472 | 508 | ||
473 | public RegionInfo GetRegionInfo(UUID regionID) | 509 | public RegionInfo GetRegionInfo(UUID regionID) |
474 | { | 510 | { |
475 | foreach (Scene scene in m_localScenes) | 511 | lock (m_localScenes) |
476 | { | 512 | { |
477 | if (scene.RegionInfo.RegionID == regionID) | 513 | foreach (Scene scene in m_localScenes) |
478 | { | 514 | { |
479 | return scene.RegionInfo; | 515 | if (scene.RegionInfo.RegionID == regionID) |
516 | { | ||
517 | return scene.RegionInfo; | ||
518 | } | ||
480 | } | 519 | } |
481 | } | 520 | } |
482 | 521 | ||
@@ -495,11 +534,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
495 | 534 | ||
496 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 535 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
497 | { | 536 | { |
498 | foreach (Scene scene in m_localScenes) | 537 | lock (m_localScenes) |
499 | { | 538 | { |
500 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 539 | foreach (Scene scene in m_localScenes) |
501 | { | 540 | { |
502 | return true; | 541 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
542 | { | ||
543 | return true; | ||
544 | } | ||
503 | } | 545 | } |
504 | } | 546 | } |
505 | 547 | ||
@@ -510,12 +552,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) | 552 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) |
511 | { | 553 | { |
512 | ScenePresence avatar = null; | 554 | ScenePresence avatar = null; |
513 | foreach (Scene mScene in m_localScenes) | 555 | |
556 | lock (m_localScenes) | ||
514 | { | 557 | { |
515 | if (mScene.TryGetScenePresence(avatarId, out avatar)) | 558 | foreach (Scene mScene in m_localScenes) |
516 | { | 559 | { |
517 | scene = mScene; | 560 | if (mScene.TryGetScenePresence(avatarId, out avatar)) |
518 | return true; | 561 | { |
562 | scene = mScene; | ||
563 | return true; | ||
564 | } | ||
519 | } | 565 | } |
520 | } | 566 | } |
521 | 567 | ||
@@ -525,17 +571,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
525 | 571 | ||
526 | public void CloseScene(Scene scene) | 572 | public void CloseScene(Scene scene) |
527 | { | 573 | { |
528 | m_localScenes.Remove(scene); | 574 | lock (m_localScenes) |
575 | m_localScenes.Remove(scene); | ||
576 | |||
529 | scene.Close(); | 577 | scene.Close(); |
530 | } | 578 | } |
531 | 579 | ||
532 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 580 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
533 | { | 581 | { |
534 | foreach (Scene scene in m_localScenes) | 582 | lock (m_localScenes) |
535 | { | 583 | { |
536 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 584 | foreach (Scene scene in m_localScenes) |
537 | { | 585 | { |
538 | return true; | 586 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
587 | { | ||
588 | return true; | ||
589 | } | ||
539 | } | 590 | } |
540 | } | 591 | } |
541 | 592 | ||
@@ -545,7 +596,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | 596 | ||
546 | public void ForEachScene(Action<Scene> action) | 597 | public void ForEachScene(Action<Scene> action) |
547 | { | 598 | { |
548 | m_localScenes.ForEach(action); | 599 | lock (m_localScenes) |
600 | m_localScenes.ForEach(action); | ||
549 | } | 601 | } |
550 | } | 602 | } |
551 | } | 603 | } |