aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorMelanie2009-10-15 21:14:13 +0100
committerMelanie2009-10-15 21:14:13 +0100
commit6deef7d0f3e9657bdc7bc4c41011dba15fea944b (patch)
treeffa84d5963afbb5390b132278c95df20b21681d5 /OpenSim/Region/Framework/Scenes
parentMerge branch 'master' into vehicles (diff)
parentMerge branch 'htb-throttle' of ssh://opensimulator.org/var/git/opensim into h... (diff)
downloadopensim-SC_OLD-6deef7d0f3e9657bdc7bc4c41011dba15fea944b.zip
opensim-SC_OLD-6deef7d0f3e9657bdc7bc4c41011dba15fea944b.tar.gz
opensim-SC_OLD-6deef7d0f3e9657bdc7bc4c41011dba15fea944b.tar.bz2
opensim-SC_OLD-6deef7d0f3e9657bdc7bc4c41011dba15fea944b.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs98
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs230
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs5
9 files changed, 264 insertions, 175 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index b6fa41d..244ac3b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
39 40
40//using HyperGrid.Framework; 41//using HyperGrid.Framework;
@@ -52,13 +53,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
52 53
53 private Scene m_scene; 54 private Scene m_scene;
54 55
55 private IHyperlinkService m_hyper; 56 private IHyperAssetService m_hyper;
56 IHyperlinkService HyperlinkService 57 IHyperAssetService HyperlinkAssets
57 { 58 {
58 get 59 get
59 { 60 {
60 if (m_hyper == null) 61 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>(); 62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
62 return m_hyper; 63 return m_hyper;
63 } 64 }
64 } 65 }
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
99 100
100 if (asset != null) 101 if (asset != null)
101 { 102 {
102 m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); 103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
103 return asset; 104 return asset;
104 } 105 }
105 return null; 106 return null;
@@ -129,6 +130,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 } 130 }
130 131
131 m_scene.AssetService.Store(asset1); 132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
132 } 134 }
133 return true; 135 return true;
134 } 136 }
@@ -167,34 +169,32 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
167 169
168 public void Get(UUID assetID, UUID ownerID) 170 public void Get(UUID assetID, UUID ownerID)
169 { 171 {
170 if (!HyperlinkService.IsLocalUser(ownerID)) 172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
171 { 177 {
172 // Get the item from the remote asset server onto the local AssetCache 178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
173 // and place an entry in m_assetMap 179 AssetBase asset = FetchAsset(userAssetURL, assetID);
174 180
175 string userAssetURL = UserAssetURL(ownerID); 181 if (asset != null)
176 if (userAssetURL != null)
177 { 182 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 183 // OK, now fetch the inside.
179 AssetBase asset = FetchAsset(userAssetURL, assetID); 184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
180 191
181 if (asset != null)
182 {
183 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
184
185 // OK, now fetch the inside.
186 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
187 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
188 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
189 foreach (UUID uuid in ids.Keys)
190 FetchAsset(userAssetURL, uuid);
191 }
192 else
193 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
194 } 192 }
195 else 193 else
196 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
197 } 195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 } 198 }
199 199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) 200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
@@ -225,44 +225,38 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
225 225
226 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
227 { 227 {
228 if (!HyperlinkService.IsLocalUser(ownerID))
229 {
230 // Post the item from the local AssetCache onto the remote asset server 228 // Post the item from the local AssetCache onto the remote asset server
231 // and place an entry in m_assetMap 229 // and place an entry in m_assetMap
232 230
233 string userAssetURL = UserAssetURL(ownerID); 231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
234 if (userAssetURL != null) 232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
235 { 237 {
236 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
237 AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); 239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
238 if (asset != null) 240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
239 { 242 {
240 Dictionary<UUID, int> ids = new Dictionary<UUID, int>(); 243 asset = m_scene.AssetService.Get(uuid.ToString());
241 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); 244 if (asset == null)
242 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); 245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
243 foreach (UUID uuid in ids.Keys) 246 else
244 {
245 asset = m_scene.AssetService.Get(uuid.ToString());
246 if (asset != null)
247 m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
248 else
249 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
250 PostAsset(userAssetURL, asset); 247 PostAsset(userAssetURL, asset);
251 } 248 }
252 249
253 if (ids.Count > 0) // maybe it succeeded... 250 // maybe all pieces got there...
254 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); 251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
255 else
256 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);
257 252
258 }
259 else
260 m_log.Debug("[HGScene]: Something wrong with asset, it could not be found");
261 } 253 }
262 else 254 else
263 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
264
265 } 256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
266 } 260 }
267 261
268 #endregion 262 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
index 8fe3565..6f7f34f 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -32,6 +32,7 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes.Hypergrid 37namespace OpenSim.Region.Framework.Scenes.Hypergrid
37{ 38{
@@ -41,6 +42,21 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 43
43 private HGAssetMapper m_assMapper; 44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
44 60
45 #endregion 61 #endregion
46 62
@@ -140,6 +156,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
140 156
141 } 157 }
142 158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
143 169
144 #endregion 170 #endregion
145 171
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9f7083f..890126f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -408,7 +408,7 @@ namespace OpenSim.Region.Framework.Scenes
408 public virtual InventoryItemBase GiveInventoryItem( 408 public virtual InventoryItemBase GiveInventoryItem(
409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) 409 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
410 { 410 {
411 Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); 411 //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
412 412
413 InventoryItemBase item = new InventoryItemBase(itemId, senderId); 413 InventoryItemBase item = new InventoryItemBase(itemId, senderId);
414 item = InventoryService.GetItem(item); 414 item = InventoryService.GetItem(item);
@@ -472,7 +472,8 @@ namespace OpenSim.Region.Framework.Scenes
472 itemCopy.SalePrice = item.SalePrice; 472 itemCopy.SalePrice = item.SalePrice;
473 itemCopy.SaleType = item.SaleType; 473 itemCopy.SaleType = item.SaleType;
474 474
475 InventoryService.AddItem(itemCopy); 475 if (InventoryService.AddItem(itemCopy))
476 TransferInventoryAssets(itemCopy, senderId, recipient);
476 477
477 if (!Permissions.BypassPermissions()) 478 if (!Permissions.BypassPermissions())
478 { 479 {
@@ -494,6 +495,10 @@ namespace OpenSim.Region.Framework.Scenes
494 495
495 } 496 }
496 497
498 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
499 {
500 }
501
497 /// <summary> 502 /// <summary>
498 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 503 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
499 /// folders) is given. 504 /// folders) is given.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 4ae4dc3..ac89f7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -390,6 +390,32 @@ namespace OpenSim.Region.Framework.Scenes
390 EventManager.TriggerScriptReset(part.LocalId, itemID); 390 EventManager.TriggerScriptReset(part.LocalId, itemID);
391 } 391 }
392 } 392 }
393
394 void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
395 {
396 // TODO: don't create new blocks if recycling an old packet
397 List<ViewerEffectPacket.EffectBlock> effectBlock = new List<ViewerEffectPacket.EffectBlock>();
398 for (int i = 0; i < args.Count; i++)
399 {
400 ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock();
401 effect.AgentID = args[i].AgentID;
402 effect.Color = args[i].Color;
403 effect.Duration = args[i].Duration;
404 effect.ID = args[i].ID;
405 effect.Type = args[i].Type;
406 effect.TypeData = args[i].TypeData;
407 effectBlock.Add(effect);
408 }
409 ViewerEffectPacket.EffectBlock[] effectBlockArray = effectBlock.ToArray();
410
411 ClientManager.ForEach(
412 delegate(IClientAPI client)
413 {
414 if (client.AgentId != remoteClient.AgentId)
415 client.SendViewerEffect(effectBlockArray);
416 }
417 );
418 }
393 419
394 /// <summary> 420 /// <summary>
395 /// Handle a fetch inventory request from the client 421 /// Handle a fetch inventory request from the client
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 03111a6..fba9ea8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -117,6 +117,8 @@ namespace OpenSim.Region.Framework.Scenes
117 private volatile bool m_backingup = false; 117 private volatile bool m_backingup = false;
118 118
119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 119 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
120
121 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
120 122
121 protected string m_simulatorVersion = "OpenSimulator Server"; 123 protected string m_simulatorVersion = "OpenSimulator Server";
122 124
@@ -246,8 +248,7 @@ namespace OpenSim.Region.Framework.Scenes
246 248
247 private int m_update_physics = 1; 249 private int m_update_physics = 1;
248 private int m_update_entitymovement = 1; 250 private int m_update_entitymovement = 1;
249 private int m_update_entities = 1; // Run through all objects checking for updates 251 private int m_update_objects = 1; // Update objects which have scheduled themselves for updates
250 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
251 private int m_update_presences = 1; // Update scene presence movements 252 private int m_update_presences = 1; // Update scene presence movements
252 private int m_update_events = 1; 253 private int m_update_events = 1;
253 private int m_update_backup = 200; 254 private int m_update_backup = 200;
@@ -867,7 +868,7 @@ namespace OpenSim.Region.Framework.Scenes
867 Thread.Sleep(500); 868 Thread.Sleep(500);
868 869
869 // Stop all client threads. 870 // Stop all client threads.
870 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); 871 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); });
871 872
872 // Stop updating the scene objects and agents. 873 // Stop updating the scene objects and agents.
873 //m_heartbeatTimer.Close(); 874 //m_heartbeatTimer.Close();
@@ -979,28 +980,7 @@ namespace OpenSim.Region.Framework.Scenes
979 maintc = Environment.TickCount; 980 maintc = Environment.TickCount;
980 981
981 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 982 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate;
982 // Aquire a lock so only one update call happens at once
983 //updateLock.WaitOne();
984 float physicsFPS = 0; 983 float physicsFPS = 0;
985 //m_log.Info("sadfadf" + m_neighbours.Count.ToString());
986 int agentsInScene = m_sceneGraph.GetRootAgentCount() + m_sceneGraph.GetChildAgentCount();
987
988 if (agentsInScene > 21)
989 {
990 if (m_update_entities == 1)
991 {
992 m_update_entities = 5;
993 StatsReporter.SetUpdateMS(6000);
994 }
995 }
996 else
997 {
998 if (m_update_entities == 5)
999 {
1000 m_update_entities = 1;
1001 StatsReporter.SetUpdateMS(3000);
1002 }
1003 }
1004 984
1005 frameMS = Environment.TickCount; 985 frameMS = Environment.TickCount;
1006 try 986 try
@@ -1013,30 +993,17 @@ namespace OpenSim.Region.Framework.Scenes
1013 m_frame = 0; 993 m_frame = 0;
1014 994
1015 otherMS = Environment.TickCount; 995 otherMS = Environment.TickCount;
1016 // run through all entities looking for updates (slow)
1017 if (m_frame % m_update_entities == 0)
1018 {
1019 /* // Adam Experimental
1020 if (m_updateEntitiesThread == null)
1021 {
1022 m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities);
1023
1024 ThreadTracker.Add(m_updateEntitiesThread);
1025 }
1026
1027 if (m_updateEntitiesThread.ThreadState == ThreadState.Stopped)
1028 m_updateEntitiesThread.Start();
1029 */
1030 996
1031 m_sceneGraph.UpdateEntities(); 997 // Check if any objects have reached their targets
1032 } 998 CheckAtTargets();
999
1000 // Update SceneObjectGroups that have scheduled themselves for updates
1001 // Objects queue their updates onto all scene presences
1002 if (m_frame % m_update_objects == 0)
1003 m_sceneGraph.UpdateObjectGroups();
1033 1004
1034 // run through entities that have scheduled themselves for 1005 // Run through all ScenePresences looking for updates
1035 // updates looking for updates(faster) 1006 // Presence updates and queued object updates for each presence are sent to clients
1036 if (m_frame % m_update_entitiesquick == 0)
1037 m_sceneGraph.ProcessUpdates();
1038
1039 // Run through scenepresences looking for updates
1040 if (m_frame % m_update_presences == 0) 1007 if (m_frame % m_update_presences == 0)
1041 m_sceneGraph.UpdatePresences(); 1008 m_sceneGraph.UpdatePresences();
1042 1009
@@ -1140,6 +1107,31 @@ namespace OpenSim.Region.Framework.Scenes
1140 } 1107 }
1141 } 1108 }
1142 1109
1110
1111 public void AddGroupTarget(SceneObjectGroup grp)
1112 {
1113 lock(m_groupsWithTargets)
1114 m_groupsWithTargets[grp.UUID] = grp;
1115 }
1116
1117 public void RemoveGroupTarget(SceneObjectGroup grp)
1118 {
1119 lock(m_groupsWithTargets)
1120 m_groupsWithTargets.Remove(grp.UUID);
1121 }
1122
1123 private void CheckAtTargets()
1124 {
1125 lock (m_groupsWithTargets)
1126 {
1127 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets)
1128 {
1129 kvp.Value.checkAtTargets();
1130 }
1131 }
1132 }
1133
1134
1143 /// <summary> 1135 /// <summary>
1144 /// Send out simstats data to all clients 1136 /// Send out simstats data to all clients
1145 /// </summary> 1137 /// </summary>
@@ -1186,10 +1178,10 @@ namespace OpenSim.Region.Framework.Scenes
1186 if (!m_backingup) 1178 if (!m_backingup)
1187 { 1179 {
1188 m_backingup = true; 1180 m_backingup = true;
1189 Thread backupthread = new Thread(Backup); 1181
1190 backupthread.Name = "BackupWriter"; 1182 System.ComponentModel.BackgroundWorker backupWorker = new System.ComponentModel.BackgroundWorker();
1191 backupthread.IsBackground = true; 1183 backupWorker.DoWork += delegate(object sender, System.ComponentModel.DoWorkEventArgs e) { Backup(); };
1192 backupthread.Start(); 1184 backupWorker.RunWorkerAsync();
1193 } 1185 }
1194 } 1186 }
1195 1187
@@ -1780,36 +1772,87 @@ namespace OpenSim.Region.Framework.Scenes
1780 1772
1781 Vector3 pos = attemptedPosition; 1773 Vector3 pos = attemptedPosition;
1782 1774
1775 int changeX = 1;
1776 int changeY = 1;
1777
1783 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) 1778 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
1784 { 1779 {
1785 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1780 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1786 { 1781 {
1787 //Border crossedBorderx = GetCrossedBorder(attemptedPosition,Cardinals.W); 1782
1788 //Border crossedBordery = GetCrossedBorder(attemptedPosition, Cardinals.S); 1783 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1784
1785 if (crossedBorderx.BorderLine.Z > 0)
1786 {
1787 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1788 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
1789 }
1790 else
1791 pos.X = ((pos.X + Constants.RegionSize));
1792
1793 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1789 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) 1794 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1790 pos.X = ((pos.X + Constants.RegionSize)); 1795
1791 pos.Y = ((pos.Y + Constants.RegionSize)); 1796 if (crossedBordery.BorderLine.Z > 0)
1797 {
1798 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1799 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1800 }
1801 else
1802 pos.Y = ((pos.Y + Constants.RegionSize));
1803
1804
1805
1792 newRegionHandle 1806 newRegionHandle
1793 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1807 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1794 (uint)((thisy - 1) * Constants.RegionSize)); 1808 (uint)((thisy - changeY) * Constants.RegionSize));
1795 // x - 1 1809 // x - 1
1796 // y - 1 1810 // y - 1
1797 } 1811 }
1798 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1812 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
1799 { 1813 {
1800 pos.X = ((pos.X + Constants.RegionSize)); 1814 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1801 pos.Y = ((pos.Y - Constants.RegionSize)); 1815
1816 if (crossedBorderx.BorderLine.Z > 0)
1817 {
1818 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1819 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1820 }
1821 else
1822 pos.X = ((pos.X + Constants.RegionSize));
1823
1824
1825 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1826 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1827
1828 if (crossedBordery.BorderLine.Z > 0)
1829 {
1830 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1831 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1832 }
1833 else
1834 pos.Y = ((pos.Y + Constants.RegionSize));
1835
1802 newRegionHandle 1836 newRegionHandle
1803 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), 1837 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1804 (uint)((thisy + 1) * Constants.RegionSize)); 1838 (uint)((thisy + changeY) * Constants.RegionSize));
1805 // x - 1 1839 // x - 1
1806 // y + 1 1840 // y + 1
1807 } 1841 }
1808 else 1842 else
1809 { 1843 {
1810 pos.X = ((pos.X + Constants.RegionSize)); 1844 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
1845
1846 if (crossedBorderx.BorderLine.Z > 0)
1847 {
1848 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
1849 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
1850 }
1851 else
1852 pos.X = ((pos.X + Constants.RegionSize));
1853
1811 newRegionHandle 1854 newRegionHandle
1812 = Util.UIntsToLong((uint) ((thisx - 1)*Constants.RegionSize), 1855 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
1813 (uint) (thisy*Constants.RegionSize)); 1856 (uint) (thisy*Constants.RegionSize));
1814 // x - 1 1857 // x - 1
1815 } 1858 }
@@ -1818,11 +1861,23 @@ namespace OpenSim.Region.Framework.Scenes
1818 { 1861 {
1819 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1862 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1820 { 1863 {
1864
1821 pos.X = ((pos.X - Constants.RegionSize)); 1865 pos.X = ((pos.X - Constants.RegionSize));
1822 pos.Y = ((pos.Y + Constants.RegionSize)); 1866 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1867 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1868
1869 if (crossedBordery.BorderLine.Z > 0)
1870 {
1871 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1872 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1873 }
1874 else
1875 pos.Y = ((pos.Y + Constants.RegionSize));
1876
1877
1823 newRegionHandle 1878 newRegionHandle
1824 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1879 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1825 (uint)((thisy - 1) * Constants.RegionSize)); 1880 (uint)((thisy - changeY) * Constants.RegionSize));
1826 // x + 1 1881 // x + 1
1827 // y - 1 1882 // y - 1
1828 } 1883 }
@@ -1831,8 +1886,8 @@ namespace OpenSim.Region.Framework.Scenes
1831 pos.X = ((pos.X - Constants.RegionSize)); 1886 pos.X = ((pos.X - Constants.RegionSize));
1832 pos.Y = ((pos.Y - Constants.RegionSize)); 1887 pos.Y = ((pos.Y - Constants.RegionSize));
1833 newRegionHandle 1888 newRegionHandle
1834 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), 1889 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1835 (uint)((thisy + 1) * Constants.RegionSize)); 1890 (uint)((thisy + changeY) * Constants.RegionSize));
1836 // x + 1 1891 // x + 1
1837 // y + 1 1892 // y + 1
1838 } 1893 }
@@ -1840,16 +1895,26 @@ namespace OpenSim.Region.Framework.Scenes
1840 { 1895 {
1841 pos.X = ((pos.X - Constants.RegionSize)); 1896 pos.X = ((pos.X - Constants.RegionSize));
1842 newRegionHandle 1897 newRegionHandle
1843 = Util.UIntsToLong((uint) ((thisx + 1)*Constants.RegionSize), 1898 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
1844 (uint) (thisy*Constants.RegionSize)); 1899 (uint) (thisy*Constants.RegionSize));
1845 // x + 1 1900 // x + 1
1846 } 1901 }
1847 } 1902 }
1848 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 1903 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
1849 { 1904 {
1850 pos.Y = ((pos.Y + Constants.RegionSize)); 1905 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
1906 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1907
1908 if (crossedBordery.BorderLine.Z > 0)
1909 {
1910 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
1911 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
1912 }
1913 else
1914 pos.Y = ((pos.Y + Constants.RegionSize));
1915
1851 newRegionHandle 1916 newRegionHandle
1852 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); 1917 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
1853 // y - 1 1918 // y - 1
1854 } 1919 }
1855 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) 1920 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
@@ -1857,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes
1857 1922
1858 pos.Y = ((pos.Y - Constants.RegionSize)); 1923 pos.Y = ((pos.Y - Constants.RegionSize));
1859 newRegionHandle 1924 newRegionHandle
1860 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1925 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
1861 // y + 1 1926 // y + 1
1862 } 1927 }
1863 1928
@@ -2363,6 +2428,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 /// <param name="client"></param> 2428 /// <param name="client"></param>
2364 public override void AddNewClient(IClientAPI client) 2429 public override void AddNewClient(IClientAPI client)
2365 { 2430 {
2431 ClientManager.Add(client);
2432
2366 CheckHeartbeat(); 2433 CheckHeartbeat();
2367 SubscribeToClientEvents(client); 2434 SubscribeToClientEvents(client);
2368 ScenePresence presence; 2435 ScenePresence presence;
@@ -2572,6 +2639,7 @@ namespace OpenSim.Region.Framework.Scenes
2572 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 2639 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
2573 { 2640 {
2574 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 2641 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
2642 client.OnViewerEffect += ProcessViewerEffect;
2575 } 2643 }
2576 2644
2577 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2645 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
@@ -2726,11 +2794,9 @@ namespace OpenSim.Region.Framework.Scenes
2726 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 2794 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
2727 { 2795 {
2728 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; 2796 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
2797 client.OnViewerEffect -= ProcessViewerEffect;
2729 } 2798 }
2730 2799
2731
2732
2733
2734 /// <summary> 2800 /// <summary>
2735 /// Teleport an avatar to their home region 2801 /// Teleport an avatar to their home region
2736 /// </summary> 2802 /// </summary>
@@ -3003,7 +3069,9 @@ namespace OpenSim.Region.Framework.Scenes
3003 agentTransactions.RemoveAgentAssetTransactions(agentID); 3069 agentTransactions.RemoveAgentAssetTransactions(agentID);
3004 } 3070 }
3005 3071
3072 // Remove the avatar from the scene
3006 m_sceneGraph.RemoveScenePresence(agentID); 3073 m_sceneGraph.RemoveScenePresence(agentID);
3074 ClientManager.Remove(agentID);
3007 3075
3008 try 3076 try
3009 { 3077 {
@@ -3053,16 +3121,6 @@ namespace OpenSim.Region.Framework.Scenes
3053 } 3121 }
3054 3122
3055 /// <summary> 3123 /// <summary>
3056 /// Closes all endpoints with the circuitcode provided.
3057 /// </summary>
3058 /// <param name="circuitcode">Circuit Code of the endpoint to close</param>
3059 public override void CloseAllAgents(uint circuitcode)
3060 {
3061 // Called by ClientView to kill all circuit codes
3062 ClientManager.CloseAllAgents(circuitcode);
3063 }
3064
3065 /// <summary>
3066 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. 3124 /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap.
3067 /// </summary> 3125 /// </summary>
3068 public void NotifyMyCoarseLocationChange() 3126 public void NotifyMyCoarseLocationChange()
@@ -3383,7 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes
3383 loggingOffUser.ControllingClient.Kick(message); 3441 loggingOffUser.ControllingClient.Kick(message);
3384 // Give them a second to receive the message! 3442 // Give them a second to receive the message!
3385 Thread.Sleep(1000); 3443 Thread.Sleep(1000);
3386 loggingOffUser.ControllingClient.Close(true); 3444 loggingOffUser.ControllingClient.Close();
3387 } 3445 }
3388 else 3446 else
3389 { 3447 {
@@ -3554,7 +3612,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 presence.ControllingClient.SendShutdownConnectionNotice(); 3612 presence.ControllingClient.SendShutdownConnectionNotice();
3555 } 3613 }
3556 3614
3557 presence.ControllingClient.Close(true); 3615 presence.ControllingClient.Close();
3558 return true; 3616 return true;
3559 } 3617 }
3560 3618
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 0ac4ed4..cf5c3c8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -196,8 +196,6 @@ namespace OpenSim.Region.Framework.Scenes
196 /// <param name="agentID"></param> 196 /// <param name="agentID"></param>
197 public abstract void RemoveClient(UUID agentID); 197 public abstract void RemoveClient(UUID agentID);
198 198
199 public abstract void CloseAllAgents(uint circuitcode);
200
201 #endregion 199 #endregion
202 200
203 /// <summary> 201 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index cda0bfc..ba5119f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes
77 77
78 protected RegionInfo m_regInfo; 78 protected RegionInfo m_regInfo;
79 protected Scene m_parentScene; 79 protected Scene m_parentScene;
80 protected Dictionary<UUID, EntityBase> m_updateList = new Dictionary<UUID, EntityBase>(); 80 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
81 protected int m_numRootAgents = 0; 81 protected int m_numRootAgents = 0;
82 protected int m_numPrim = 0; 82 protected int m_numPrim = 0;
83 protected int m_numChildAgents = 0; 83 protected int m_numChildAgents = 0;
@@ -155,16 +155,6 @@ namespace OpenSim.Region.Framework.Scenes
155 } 155 }
156 } 156 }
157 157
158 protected internal void UpdateEntities()
159 {
160 List<EntityBase> updateEntities = GetEntities();
161
162 foreach (EntityBase entity in updateEntities)
163 {
164 entity.Update();
165 }
166 }
167
168 protected internal void UpdatePresences() 158 protected internal void UpdatePresences()
169 { 159 {
170 List<ScenePresence> updateScenePresences = GetScenePresences(); 160 List<ScenePresence> updateScenePresences = GetScenePresences();
@@ -365,12 +355,12 @@ namespace OpenSim.Region.Framework.Scenes
365 } 355 }
366 356
367 /// <summary> 357 /// <summary>
368 /// Add an entity to the list of prims to process on the next update 358 /// Add an object to the list of prims to process on the next update
369 /// </summary> 359 /// </summary>
370 /// <param name="obj"> 360 /// <param name="obj">
371 /// A <see cref="EntityBase"/> 361 /// A <see cref="SceneObjectGroup"/>
372 /// </param> 362 /// </param>
373 protected internal void AddToUpdateList(EntityBase obj) 363 protected internal void AddToUpdateList(SceneObjectGroup obj)
374 { 364 {
375 lock (m_updateList) 365 lock (m_updateList)
376 { 366 {
@@ -381,18 +371,18 @@ namespace OpenSim.Region.Framework.Scenes
381 /// <summary> 371 /// <summary>
382 /// Process all pending updates 372 /// Process all pending updates
383 /// </summary> 373 /// </summary>
384 protected internal void ProcessUpdates() 374 protected internal void UpdateObjectGroups()
385 { 375 {
386 Dictionary<UUID, EntityBase> updates; 376 Dictionary<UUID, SceneObjectGroup> updates;
387 // Some updates add more updates to the updateList. 377 // Some updates add more updates to the updateList.
388 // Get the current list of updates and clear the list before iterating 378 // Get the current list of updates and clear the list before iterating
389 lock (m_updateList) 379 lock (m_updateList)
390 { 380 {
391 updates = new Dictionary<UUID, EntityBase>(m_updateList); 381 updates = new Dictionary<UUID, SceneObjectGroup>(m_updateList);
392 m_updateList.Clear(); 382 m_updateList.Clear();
393 } 383 }
394 // Go through all timers 384 // Go through all updates
395 foreach (KeyValuePair<UUID, EntityBase> kvp in updates) 385 foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in updates)
396 { 386 {
397 // Don't abort the whole update if one entity happens to give us an exception. 387 // Don't abort the whole update if one entity happens to give us an exception.
398 try 388 try
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index be8a6c9..b8bd9b4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1241,6 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes
1241 { 1241 {
1242 lock (m_targets) 1242 lock (m_targets)
1243 m_targets.Clear(); 1243 m_targets.Clear();
1244 m_scene.RemoveGroupTarget(this);
1244 } 1245 }
1245 1246
1246 ScheduleGroupForFullUpdate(); 1247 ScheduleGroupForFullUpdate();
@@ -1871,12 +1872,6 @@ namespace OpenSim.Region.Framework.Scenes
1871 m_rootPart.UpdateFlag = 1; 1872 m_rootPart.UpdateFlag = 1;
1872 lastPhysGroupPos = AbsolutePosition; 1873 lastPhysGroupPos = AbsolutePosition;
1873 } 1874 }
1874 //foreach (SceneObjectPart part in m_parts.Values)
1875 //{
1876 //if (part.UpdateFlag == 0) part.UpdateFlag = 1;
1877 //}
1878
1879 checkAtTargets();
1880 1875
1881 if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) 1876 if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
1882 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) 1877 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
@@ -3126,6 +3121,7 @@ namespace OpenSim.Region.Framework.Scenes
3126 { 3121 {
3127 m_targets.Add(handle, waypoint); 3122 m_targets.Add(handle, waypoint);
3128 } 3123 }
3124 m_scene.AddGroupTarget(this);
3129 return (int)handle; 3125 return (int)handle;
3130 } 3126 }
3131 3127
@@ -3133,12 +3129,13 @@ namespace OpenSim.Region.Framework.Scenes
3133 { 3129 {
3134 lock (m_targets) 3130 lock (m_targets)
3135 { 3131 {
3136 if (m_targets.ContainsKey((uint)handle)) 3132 m_targets.Remove((uint)handle);
3137 m_targets.Remove((uint)handle); 3133 if (m_targets.Count == 0)
3134 m_scene.RemoveGroupTarget(this);
3138 } 3135 }
3139 } 3136 }
3140 3137
3141 private void checkAtTargets() 3138 public void checkAtTargets()
3142 { 3139 {
3143 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) 3140 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
3144 { 3141 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 5c9e66f..8230f32 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -61,11 +61,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 throw new NotImplementedException(); 61 throw new NotImplementedException();
62 } 62 }
63 63
64 public override void CloseAllAgents(uint circuitcode)
65 {
66 throw new NotImplementedException();
67 }
68
69 public override void OtherRegionUp(GridRegion otherRegion) 64 public override void OtherRegionUp(GridRegion otherRegion)
70 { 65 {
71 throw new NotImplementedException(); 66 throw new NotImplementedException();