aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs342
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs52
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs173
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs137
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs70
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs1
17 files changed, 520 insertions, 276 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e2d96d9..fcbcf59 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -321,6 +321,8 @@ namespace OpenSim.Region.Framework.Scenes
321 // Passing something to another avatar or a an object will already 321 // Passing something to another avatar or a an object will already
322 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 322 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
323 item = InventoryService.GetItem(item); 323 item = InventoryService.GetItem(item);
324 if (item.Owner != remoteClient.AgentId)
325 return;
324 326
325 if (item != null) 327 if (item != null)
326 { 328 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 355671c..1a6a70b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -83,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes
83 public bool m_useFlySlow; 83 public bool m_useFlySlow;
84 public bool m_usePreJump; 84 public bool m_usePreJump;
85 public bool m_seeIntoRegionFromNeighbor; 85 public bool m_seeIntoRegionFromNeighbor;
86
87 protected float m_defaultDrawDistance = 255.0f;
88 public float DefaultDrawDistance
89 {
90 get { return m_defaultDrawDistance; }
91 }
92
86 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
87 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
88 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
@@ -129,7 +136,16 @@ namespace OpenSim.Region.Framework.Scenes
129 protected ICapabilitiesModule m_capsModule; 136 protected ICapabilitiesModule m_capsModule;
130 // Central Update Loop 137 // Central Update Loop
131 protected int m_fps = 10; 138 protected int m_fps = 10;
132 protected uint m_frame; 139
140 /// <summary>
141 /// Current scene frame number
142 /// </summary>
143 public uint Frame
144 {
145 get;
146 protected set;
147 }
148
133 protected float m_timespan = 0.089f; 149 protected float m_timespan = 0.089f;
134 protected DateTime m_lastupdate = DateTime.UtcNow; 150 protected DateTime m_lastupdate = DateTime.UtcNow;
135 151
@@ -618,6 +634,8 @@ namespace OpenSim.Region.Framework.Scenes
618 // 634 //
619 IConfig startupConfig = m_config.Configs["Startup"]; 635 IConfig startupConfig = m_config.Configs["Startup"];
620 636
637 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
638
621 //Animation states 639 //Animation states
622 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 640 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
623 // TODO: Change default to true once the feature is supported 641 // TODO: Change default to true once the feature is supported
@@ -1183,7 +1201,8 @@ namespace OpenSim.Region.Framework.Scenes
1183 1201
1184 try 1202 try
1185 { 1203 {
1186 Update(); 1204 while (!shuttingdown)
1205 Update();
1187 1206
1188 m_lastUpdate = Util.EnvironmentTickCount(); 1207 m_lastUpdate = Util.EnvironmentTickCount();
1189 m_firstHeartbeat = false; 1208 m_firstHeartbeat = false;
@@ -1200,187 +1219,176 @@ namespace OpenSim.Region.Framework.Scenes
1200 Watchdog.RemoveThread(); 1219 Watchdog.RemoveThread();
1201 } 1220 }
1202 1221
1203 /// <summary>
1204 /// Performs per-frame updates on the scene, this should be the central scene loop
1205 /// </summary>
1206 public override void Update() 1222 public override void Update()
1207 { 1223 {
1208 float physicsFPS; 1224 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1209 int maintc; 1225 float physicsFPS = 0f;
1210 1226
1211 while (!shuttingdown) 1227 int maintc = Util.EnvironmentTickCount();
1228 int tmpFrameMS = maintc;
1229 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1230
1231 // Increment the frame counter
1232 ++Frame;
1233
1234 try
1212 { 1235 {
1213 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1236 // Check if any objects have reached their targets
1214 physicsFPS = 0f; 1237 CheckAtTargets();
1215 1238
1216 maintc = Util.EnvironmentTickCount(); 1239 // Update SceneObjectGroups that have scheduled themselves for updates
1217 int tmpFrameMS = maintc; 1240 // Objects queue their updates onto all scene presences
1218 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1241 if (Frame % m_update_objects == 0)
1242 m_sceneGraph.UpdateObjectGroups();
1219 1243
1220 // Increment the frame counter 1244 // Run through all ScenePresences looking for updates
1221 ++m_frame; 1245 // Presence updates and queued object updates for each presence are sent to clients
1246 if (Frame % m_update_presences == 0)
1247 m_sceneGraph.UpdatePresences();
1222 1248
1223 try 1249 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1250 if (Frame % m_update_coarse_locations == 0)
1224 { 1251 {
1225 // Check if any objects have reached their targets 1252 List<Vector3> coarseLocations;
1226 CheckAtTargets(); 1253 List<UUID> avatarUUIDs;
1254 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1255 // Send coarse locations to clients
1256 ForEachScenePresence(delegate(ScenePresence presence)
1257 {
1258 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1259 });
1260 }
1227 1261
1228 // Update SceneObjectGroups that have scheduled themselves for updates 1262 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1229 // Objects queue their updates onto all scene presences 1263 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1230 if (m_frame % m_update_objects == 0) 1264 m_sceneGraph.UpdatePreparePhysics();
1231 m_sceneGraph.UpdateObjectGroups(); 1265 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1232 1266
1233 // Run through all ScenePresences looking for updates 1267 // Apply any pending avatar force input to the avatar's velocity
1234 // Presence updates and queued object updates for each presence are sent to clients 1268 if (Frame % m_update_entitymovement == 0)
1235 if (m_frame % m_update_presences == 0) 1269 m_sceneGraph.UpdateScenePresenceMovement();
1236 m_sceneGraph.UpdatePresences();
1237 1270
1238 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) 1271 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1239 if (m_frame % m_update_coarse_locations == 0) 1272 // velocity
1240 { 1273 int tmpPhysicsMS = Util.EnvironmentTickCount();
1241 List<Vector3> coarseLocations; 1274 if (Frame % m_update_physics == 0)
1242 List<UUID> avatarUUIDs; 1275 {
1243 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); 1276 if (m_physics_enabled)
1244 // Send coarse locations to clients 1277 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
1245 ForEachScenePresence(delegate(ScenePresence presence) 1278 if (SynchronizeScene != null)
1246 { 1279 SynchronizeScene(this);
1247 presence.SendCoarseLocations(coarseLocations, avatarUUIDs); 1280 }
1248 }); 1281 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1249 }
1250
1251 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1252 if ((m_frame % m_update_physics == 0) && m_physics_enabled)
1253 m_sceneGraph.UpdatePreparePhysics();
1254 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1255 1282
1256 // Apply any pending avatar force input to the avatar's velocity 1283 // Delete temp-on-rez stuff
1257 if (m_frame % m_update_entitymovement == 0) 1284 if (Frame % 1000 == 0 && !m_cleaningTemps)
1258 m_sceneGraph.UpdateScenePresenceMovement(); 1285 {
1286 int tmpTempOnRezMS = Util.EnvironmentTickCount();
1287 m_cleaningTemps = true;
1288 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1289 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1290 }
1259 1291
1260 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1292 if (RegionStatus != RegionStatus.SlaveScene)
1261 // velocity 1293 {
1262 int tmpPhysicsMS = Util.EnvironmentTickCount(); 1294 if (Frame % m_update_events == 0)
1263 if (m_frame % m_update_physics == 0)
1264 { 1295 {
1265 if (m_physics_enabled) 1296 int evMS = Util.EnvironmentTickCount();
1266 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); 1297 UpdateEvents();
1267 if (SynchronizeScene != null) 1298 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1268 SynchronizeScene(this);
1269 } 1299 }
1270 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1271 1300
1272 // Delete temp-on-rez stuff 1301 if (Frame % m_update_backup == 0)
1273 if (m_frame % 1000 == 0 && !m_cleaningTemps)
1274 { 1302 {
1275 int tmpTempOnRezMS = Util.EnvironmentTickCount(); 1303 int backMS = Util.EnvironmentTickCount();
1276 m_cleaningTemps = true; 1304 UpdateStorageBackup();
1277 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1305 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1278 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1279 } 1306 }
1280 1307
1281 if (RegionStatus != RegionStatus.SlaveScene) 1308 if (Frame % m_update_terrain == 0)
1282 { 1309 {
1283 if (m_frame % m_update_events == 0) 1310 int terMS = Util.EnvironmentTickCount();
1284 { 1311 UpdateTerrain();
1285 int evMS = Util.EnvironmentTickCount(); 1312 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1286 UpdateEvents(); 1313 }
1287 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1288 }
1289
1290 if (m_frame % m_update_backup == 0)
1291 {
1292 int backMS = Util.EnvironmentTickCount();
1293 UpdateStorageBackup();
1294 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1295 }
1296 1314
1297 if (m_frame % m_update_terrain == 0) 1315 //if (Frame % m_update_land == 0)
1298 { 1316 //{
1299 int terMS = Util.EnvironmentTickCount(); 1317 // int ldMS = Util.EnvironmentTickCount();
1300 UpdateTerrain(); 1318 // UpdateLand();
1301 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1319 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1302 } 1320 //}
1303 1321
1304 //if (m_frame % m_update_land == 0) 1322 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1305 //{ 1323 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1306 // int ldMS = Util.EnvironmentTickCount(); 1324 lastCompletedFrame = Util.EnvironmentTickCount();
1307 // UpdateLand(); 1325
1308 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1326 // if (Frame%m_update_avatars == 0)
1309 //} 1327 // UpdateInWorldTime();
1328 StatsReporter.AddPhysicsFPS(physicsFPS);
1329 StatsReporter.AddTimeDilation(TimeDilation);
1330 StatsReporter.AddFPS(1);
1331 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1332 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1333 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1334 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1335 StatsReporter.addFrameMS(frameMS);
1336 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1337 StatsReporter.addOtherMS(otherMS);
1338 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1339 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1340 }
1310 1341
1311 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1342 if (LoginsDisabled && Frame == 20)
1312 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1343 {
1313 lastCompletedFrame = Util.EnvironmentTickCount(); 1344 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1314 1345 // this is a rare case where we know we have just went through a long cycle of heap
1315 // if (m_frame%m_update_avatars == 0) 1346 // allocations, and there is no more work to be done until someone logs in
1316 // UpdateInWorldTime(); 1347 GC.Collect();
1317 StatsReporter.AddPhysicsFPS(physicsFPS);
1318 StatsReporter.AddTimeDilation(TimeDilation);
1319 StatsReporter.AddFPS(1);
1320 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1321 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1322 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1323 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1324 StatsReporter.addFrameMS(frameMS);
1325 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1326 StatsReporter.addOtherMS(otherMS);
1327 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1328 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1329 }
1330 1348
1331 if (LoginsDisabled && m_frame == 20) 1349 IConfig startupConfig = m_config.Configs["Startup"];
1350 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
1332 { 1351 {
1333 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1352 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1334 // this is a rare case where we know we have just went through a long cycle of heap 1353 LoginsDisabled = false;
1335 // allocations, and there is no more work to be done until someone logs in 1354 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1336 GC.Collect();
1337
1338 IConfig startupConfig = m_config.Configs["Startup"];
1339 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
1340 {
1341 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1342 LoginsDisabled = false;
1343 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1344 }
1345 } 1355 }
1346 } 1356 }
1347 catch (NotImplementedException) 1357 }
1348 { 1358 catch (NotImplementedException)
1349 throw; 1359 {
1350 } 1360 throw;
1351 catch (AccessViolationException e) 1361 }
1352 { 1362 catch (AccessViolationException e)
1353 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1363 {
1354 } 1364 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1355 //catch (NullReferenceException e) 1365 }
1356 //{ 1366 //catch (NullReferenceException e)
1357 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1367 //{
1358 //} 1368 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1359 catch (InvalidOperationException e) 1369 //}
1360 { 1370 catch (InvalidOperationException e)
1361 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1371 {
1362 } 1372 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1363 catch (Exception e) 1373 }
1364 { 1374 catch (Exception e)
1365 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1375 {
1366 } 1376 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1367 finally 1377 }
1368 { 1378 finally
1369 m_lastupdate = DateTime.UtcNow; 1379 {
1370 } 1380 m_lastupdate = DateTime.UtcNow;
1371 1381 }
1372 maintc = Util.EnvironmentTickCountSubtract(maintc);
1373 maintc = (int)(m_timespan * 1000) - maintc;
1374 1382
1375 if (maintc > 0) 1383 maintc = Util.EnvironmentTickCountSubtract(maintc);
1376 Thread.Sleep(maintc); 1384 maintc = (int)(m_timespan * 1000) - maintc;
1377 1385
1378 // Tell the watchdog that this thread is still alive 1386 if (maintc > 0)
1379 Watchdog.UpdateThread(); 1387 Thread.Sleep(maintc);
1380 }
1381 }
1382 1388
1383 1389 // Tell the watchdog that this thread is still alive
1390 Watchdog.UpdateThread();
1391 }
1384 1392
1385 public void AddGroupTarget(SceneObjectGroup grp) 1393 public void AddGroupTarget(SceneObjectGroup grp)
1386 { 1394 {
@@ -3011,7 +3019,9 @@ namespace OpenSim.Region.Framework.Scenes
3011 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 3019 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
3012 3020
3013 m_sceneGraph.removeUserCount(!childagentYN); 3021 m_sceneGraph.removeUserCount(!childagentYN);
3014 CapsModule.RemoveCapsHandler(agentID); 3022
3023 if (CapsModule != null)
3024 CapsModule.RemoveCapsHandler(agentID);
3015 3025
3016 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3026 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3017 // this method is doing is HORRIBLE!!! 3027 // this method is doing is HORRIBLE!!!
@@ -3200,7 +3210,7 @@ namespace OpenSim.Region.Framework.Scenes
3200 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport 3210 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
3201 3211
3202 // Don't disable this log message - it's too helpful 3212 // Don't disable this log message - it's too helpful
3203 m_log.InfoFormat( 3213 m_log.DebugFormat(
3204 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", 3214 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})",
3205 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3215 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3206 agent.AgentID, agent.circuitcode, teleportFlags); 3216 agent.AgentID, agent.circuitcode, teleportFlags);
@@ -3266,8 +3276,11 @@ namespace OpenSim.Region.Framework.Scenes
3266 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3276 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3267 agent.AgentID, agent.circuitcode); 3277 agent.AgentID, agent.circuitcode);
3268 3278
3269 CapsModule.NewUserConnection(agent); 3279 if (CapsModule != null)
3270 CapsModule.AddCapsHandler(agent.AgentID); 3280 {
3281 CapsModule.NewUserConnection(agent);
3282 CapsModule.AddCapsHandler(agent.AgentID);
3283 }
3271 } 3284 }
3272 else 3285 else
3273 { 3286 {
@@ -3282,7 +3295,9 @@ namespace OpenSim.Region.Framework.Scenes
3282 agent.AgentID, RegionInfo.RegionName); 3295 agent.AgentID, RegionInfo.RegionName);
3283 3296
3284 sp.AdjustKnownSeeds(); 3297 sp.AdjustKnownSeeds();
3285 CapsModule.NewUserConnection(agent); 3298
3299 if (CapsModule != null)
3300 CapsModule.NewUserConnection(agent);
3286 } 3301 }
3287 } 3302 }
3288 3303
@@ -3770,15 +3785,15 @@ namespace OpenSim.Region.Framework.Scenes
3770 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3785 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3771 Vector3 lookat, uint teleportFlags) 3786 Vector3 lookat, uint teleportFlags)
3772 { 3787 {
3773 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); 3788 List<GridRegion> regions = GridService.GetRegionsByName(RegionInfo.ScopeID, regionName, 1);
3774 if (regionInfo == null) 3789 if (regions == null || regions.Count == 0)
3775 { 3790 {
3776 // can't find the region: Tell viewer and abort 3791 // can't find the region: Tell viewer and abort
3777 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); 3792 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
3778 return; 3793 return;
3779 } 3794 }
3780 3795
3781 RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); 3796 RequestTeleportLocation(remoteClient, regions[0].RegionHandle, position, lookat, teleportFlags);
3782 } 3797 }
3783 3798
3784 /// <summary> 3799 /// <summary>
@@ -4923,8 +4938,9 @@ namespace OpenSim.Region.Framework.Scenes
4923 // from logging into the region, teleporting into the region 4938 // from logging into the region, teleporting into the region
4924 // or corssing the broder walking, but will NOT prevent 4939 // or corssing the broder walking, but will NOT prevent
4925 // child agent creation, thereby emulating the SL behavior. 4940 // child agent creation, thereby emulating the SL behavior.
4926 public bool QueryAccess(UUID agentID, Vector3 position) 4941 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4927 { 4942 {
4943 reason = String.Empty;
4928 return true; 4944 return true;
4929 } 4945 }
4930 } 4946 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 969ff13..734ba22 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -204,9 +204,10 @@ namespace OpenSim.Region.Framework.Scenes
204 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) 204 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i)
205 { 205 {
206 ScenePresence sp = presences[i]; 206 ScenePresence sp = presences[i];
207
207 // If this presence is a child agent, we don't want its coarse locations 208 // If this presence is a child agent, we don't want its coarse locations
208 if (sp.IsChildAgent) 209 if (sp.IsChildAgent)
209 return; 210 continue;
210 211
211 if (sp.ParentID != 0) 212 if (sp.ParentID != 0)
212 { 213 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 67e59c6..fa404c0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1089,9 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes
1089 1089
1090 public Dictionary<UUID, string> GetScriptStates() 1090 public Dictionary<UUID, string> GetScriptStates()
1091 { 1091 {
1092 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1093
1094 if (m_part.ParentGroup.Scene == null) // Group not in a scene
1095 return ret;
1096
1092 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 1097 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1093 1098
1094 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1095 if (engines == null) // No engine at all 1099 if (engines == null) // No engine at all
1096 return ret; 1100 return ret;
1097 1101
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cd70de8..00a1487 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -626,7 +626,7 @@ namespace OpenSim.Region.Framework.Scenes
626 Utils.LongToUInts(handle, out x, out y); 626 Utils.LongToUInts(handle, out x, out y);
627 x = x / Constants.RegionSize; 627 x = x / Constants.RegionSize;
628 y = y / Constants.RegionSize; 628 y = y / Constants.RegionSize;
629 if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 629 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
630 { 630 {
631 old.Add(handle); 631 old.Add(handle);
632 } 632 }
@@ -700,6 +700,7 @@ namespace OpenSim.Region.Framework.Scenes
700 700
701 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() 701 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
702 { 702 {
703 m_DrawDistance = world.DefaultDrawDistance;
703 m_rootRegionHandle = reginfo.RegionHandle; 704 m_rootRegionHandle = reginfo.RegionHandle;
704 m_controllingClient = client; 705 m_controllingClient = client;
705 m_firstname = m_controllingClient.FirstName; 706 m_firstname = m_controllingClient.FirstName;
@@ -1161,7 +1162,9 @@ namespace OpenSim.Region.Framework.Scenes
1161 if (m_agentTransfer != null) 1162 if (m_agentTransfer != null)
1162 m_agentTransfer.EnableChildAgents(this); 1163 m_agentTransfer.EnableChildAgents(this);
1163 else 1164 else
1164 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); 1165 m_log.DebugFormat(
1166 "[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}",
1167 m_scene.RegionInfo.RegionName);
1165 1168
1166 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1169 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1167 if (friendsModule != null) 1170 if (friendsModule != null)
@@ -1277,7 +1280,11 @@ namespace OpenSim.Region.Framework.Scenes
1277 m_CameraUpAxis = agentData.CameraUpAxis; 1280 m_CameraUpAxis = agentData.CameraUpAxis;
1278 1281
1279 // The Agent's Draw distance setting 1282 // The Agent's Draw distance setting
1280 m_DrawDistance = agentData.Far; 1283 // When we get to the point of re-computing neighbors everytime this
1284 // changes, then start using the agent's drawdistance rather than the
1285 // region's draw distance.
1286 // m_DrawDistance = agentData.Far;
1287 m_DrawDistance = Scene.DefaultDrawDistance;
1281 1288
1282 // Check if Client has camera in 'follow cam' or 'build' mode. 1289 // Check if Client has camera in 'follow cam' or 'build' mode.
1283 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); 1290 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
@@ -2435,7 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes
2435 // If we are using the the cached appearance then send it out to everyone 2442 // If we are using the the cached appearance then send it out to everyone
2436 if (cachedappearance) 2443 if (cachedappearance)
2437 { 2444 {
2438 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2445 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2439 2446
2440 // If the avatars baked textures are all in the cache, then we have a 2447 // If the avatars baked textures are all in the cache, then we have a
2441 // complete appearance... send it out, if not, then we'll send it when 2448 // complete appearance... send it out, if not, then we'll send it when
@@ -2652,8 +2659,11 @@ namespace OpenSim.Region.Framework.Scenes
2652 #region Border Crossing Methods 2659 #region Border Crossing Methods
2653 2660
2654 /// <summary> 2661 /// <summary>
2655 /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion 2662 /// Starts the process of moving an avatar into another region if they are crossing the border.
2656 /// </summary> 2663 /// </summary>
2664 /// <remarks>
2665 /// Also removes the avatar from the physical scene if transit has started.
2666 /// </remarks>
2657 protected void CheckForBorderCrossing() 2667 protected void CheckForBorderCrossing()
2658 { 2668 {
2659 if (IsChildAgent) 2669 if (IsChildAgent)
@@ -2721,7 +2731,6 @@ namespace OpenSim.Region.Framework.Scenes
2721 neighbor = HaveNeighbor(Cardinals.N, ref fix); 2731 neighbor = HaveNeighbor(Cardinals.N, ref fix);
2722 } 2732 }
2723 2733
2724
2725 // Makes sure avatar does not end up outside region 2734 // Makes sure avatar does not end up outside region
2726 if (neighbor <= 0) 2735 if (neighbor <= 0)
2727 { 2736 {
@@ -2776,6 +2785,13 @@ namespace OpenSim.Region.Framework.Scenes
2776 } 2785 }
2777 else 2786 else
2778 { 2787 {
2788 // We must remove the agent from the physical scene if it has been placed in transit. If we don't,
2789 // then this method continues to be called from ScenePresence.Update() until the handover of the client between
2790 // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms
2791 // event queue polling response from the server), this results in the avatar pausing on the border
2792 // for the handover period.
2793 RemoveFromPhysicalScene();
2794
2779 // This constant has been inferred from experimentation 2795 // This constant has been inferred from experimentation
2780 // I'm not sure what this value should be, so I tried a few values. 2796 // I'm not sure what this value should be, so I tried a few values.
2781 timeStep = 0.04f; 2797 timeStep = 0.04f;
@@ -2787,6 +2803,15 @@ namespace OpenSim.Region.Framework.Scenes
2787 } 2803 }
2788 } 2804 }
2789 2805
2806 /// <summary>
2807 /// Checks whether this region has a neighbour in the given direction.
2808 /// </summary>
2809 /// <param name="car"></param>
2810 /// <param name="fix"></param>
2811 /// <returns>
2812 /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
2813 /// Returns a positive integer if there is a region in that direction, a negative integer if not.
2814 /// </returns>
2790 protected int HaveNeighbor(Cardinals car, ref int[] fix) 2815 protected int HaveNeighbor(Cardinals car, ref int[] fix)
2791 { 2816 {
2792 uint neighbourx = m_regionInfo.RegionLocX; 2817 uint neighbourx = m_regionInfo.RegionLocX;
@@ -2893,7 +2918,7 @@ namespace OpenSim.Region.Framework.Scenes
2893 2918
2894 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 2919 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
2895 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 2920 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
2896 if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) 2921 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
2897 { 2922 {
2898 byebyeRegions.Add(handle); 2923 byebyeRegions.Add(handle);
2899 } 2924 }
@@ -2969,7 +2994,12 @@ namespace OpenSim.Region.Framework.Scenes
2969 2994
2970 Vector3 offset = new Vector3(shiftx, shifty, 0f); 2995 Vector3 offset = new Vector3(shiftx, shifty, 0f);
2971 2996
2972 m_DrawDistance = cAgentData.Far; 2997 // When we get to the point of re-computing neighbors everytime this
2998 // changes, then start using the agent's drawdistance rather than the
2999 // region's draw distance.
3000 // m_DrawDistance = cAgentData.Far;
3001 m_DrawDistance = Scene.DefaultDrawDistance;
3002
2973 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! 3003 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!!
2974 m_pos = cAgentData.Position + offset; 3004 m_pos = cAgentData.Position + offset;
2975 3005
@@ -3119,7 +3149,11 @@ namespace OpenSim.Region.Framework.Scenes
3119 m_CameraLeftAxis = cAgent.LeftAxis; 3149 m_CameraLeftAxis = cAgent.LeftAxis;
3120 m_CameraUpAxis = cAgent.UpAxis; 3150 m_CameraUpAxis = cAgent.UpAxis;
3121 3151
3122 m_DrawDistance = cAgent.Far; 3152 // When we get to the point of re-computing neighbors everytime this
3153 // changes, then start using the agent's drawdistance rather than the
3154 // region's draw distance.
3155 // m_DrawDistance = cAgent.Far;
3156 m_DrawDistance = Scene.DefaultDrawDistance;
3123 3157
3124 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 3158 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
3125 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 3159 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
new file mode 100644
index 0000000..855b589
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
@@ -0,0 +1,173 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Attachment tests
52 /// </summary>
53 [TestFixture]
54 public class AttachmentTests
55 {
56 public Scene scene, scene2;
57 public UUID agent1;
58 public static Random random;
59 public ulong region1, region2;
60 public AgentCircuitData acd1;
61 public SceneObjectGroup sog1, sog2, sog3;
62
63 [TestFixtureSetUp]
64 public void Init()
65 {
66 TestHelper.InMethod();
67
68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
70
71 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
72 interregionComms.Initialise(new IniConfigSource());
73 interregionComms.PostInitialise();
74 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
75 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
76
77 agent1 = UUID.Random();
78 random = new Random();
79 sog1 = NewSOG(UUID.Random(), scene, agent1);
80 sog2 = NewSOG(UUID.Random(), scene, agent1);
81 sog3 = NewSOG(UUID.Random(), scene, agent1);
82
83 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
84 region1 = scene.RegionInfo.RegionHandle;
85 region2 = scene2.RegionInfo.RegionHandle;
86
87 SceneSetupHelpers.AddRootAgent(scene, agent1);
88 }
89
90 [Test]
91 public void T030_TestAddAttachments()
92 {
93 TestHelper.InMethod();
94
95 ScenePresence presence = scene.GetScenePresence(agent1);
96
97 presence.AddAttachment(sog1);
98 presence.AddAttachment(sog2);
99 presence.AddAttachment(sog3);
100
101 Assert.That(presence.HasAttachments(), Is.True);
102 Assert.That(presence.ValidateAttachments(), Is.True);
103 }
104
105 [Test]
106 public void T031_RemoveAttachments()
107 {
108 TestHelper.InMethod();
109
110 ScenePresence presence = scene.GetScenePresence(agent1);
111 presence.RemoveAttachment(sog1);
112 presence.RemoveAttachment(sog2);
113 presence.RemoveAttachment(sog3);
114 Assert.That(presence.HasAttachments(), Is.False);
115 }
116
117 // I'm commenting this test because scene setup NEEDS InventoryService to
118 // be non-null
119 //[Test]
120 public void T032_CrossAttachments()
121 {
122 TestHelper.InMethod();
123
124 ScenePresence presence = scene.GetScenePresence(agent1);
125 ScenePresence presence2 = scene2.GetScenePresence(agent1);
126 presence2.AddAttachment(sog1);
127 presence2.AddAttachment(sog2);
128
129 ISharedRegionModule serialiser = new SerialiserModule();
130 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
131 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
132
133 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
134
135 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
136 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
137 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
138 }
139
140 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
141 {
142 SceneObjectPart sop = new SceneObjectPart();
143 sop.Name = RandomName();
144 sop.Description = RandomName();
145 sop.Text = RandomName();
146 sop.SitName = RandomName();
147 sop.TouchName = RandomName();
148 sop.UUID = uuid;
149 sop.Shape = PrimitiveBaseShape.Default;
150 sop.Shape.State = 1;
151 sop.OwnerID = agent;
152
153 SceneObjectGroup sog = new SceneObjectGroup(sop);
154 sog.SetScene(scene);
155
156 return sog;
157 }
158
159 private static string RandomName()
160 {
161 StringBuilder name = new StringBuilder();
162 int size = random.Next(5,12);
163 char ch;
164 for (int i = 0; i < size; i++)
165 {
166 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
167 name.Append(ch);
168 }
169
170 return name.ToString();
171 }
172 }
173} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index b3c3e22..667b74e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -32,7 +32,6 @@ using System.Text;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using Nini.Config; 33using Nini.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 9244bc3..ca635d7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 4969b09..a6a95ef 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 39116b6..0d26026 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index b84298f..bdfcd1d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c78038f..8876a43 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index ef52363..efb757f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -34,12 +34,12 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenSim.Framework; 38using OpenSim.Framework;
40using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer;
43using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
@@ -116,9 +116,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); 116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
117 agent.child = true; 117 agent.child = true;
118 118
119 if (scene.PresenceService == null)
120 Console.WriteLine("Presence Service is null");
121
122 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); 119 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
123 120
124 string reason; 121 string reason;
@@ -175,25 +172,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
175 172
176 Assert.That(neighbours.Count, Is.EqualTo(2)); 173 Assert.That(neighbours.Count, Is.EqualTo(2));
177 } 174 }
178
179 public void fixNullPresence()
180 {
181 string firstName = "testfirstname";
182
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = agent1;
185 agent.firstname = firstName;
186 agent.lastname = "testlastname";
187 agent.SessionID = UUID.Zero;
188 agent.SecureSessionID = UUID.Zero;
189 agent.circuitcode = 123;
190 agent.BaseFolder = UUID.Zero;
191 agent.InventoryFolder = UUID.Zero;
192 agent.startpos = Vector3.Zero;
193 agent.CapsPath = GetRandomCapsObjectPath();
194
195 acd1 = agent;
196 }
197 175
198 [Test] 176 [Test]
199 public void T013_TestRemoveNeighbourRegion() 177 public void T013_TestRemoveNeighbourRegion()
@@ -211,24 +189,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
211 CompleteAvatarMovement 189 CompleteAvatarMovement
212 */ 190 */
213 } 191 }
214 192
215 // I'm commenting this test, because this is not supposed to happen here 193 /// <summary>
216 //[Test] 194 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
217 public void T020_TestMakeRootAgent() 195 /// </summary>
196 /// <remarks>
197 /// Please note that unlike the other tests here, this doesn't rely on structures
198 /// </remarks>
199 [Test]
200 public void TestChildAgentEstablished()
218 { 201 {
219 TestHelper.InMethod(); 202 TestHelper.InMethod();
220 203// log4net.Config.XmlConfigurator.Configure();
221 ScenePresence presence = scene.GetScenePresence(agent1); 204
222 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); 205 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
223 206
224 presence.MakeChildAgent(); 207 TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
225 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); 208 TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
226 209
227 // Accepts 0 but rejects Constants.RegionSize 210 IConfigSource configSource = new IniConfigSource();
228 Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); 211 configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
229 presence.MakeRootAgent(pos,true); 212 EntityTransferModule etm = new EntityTransferModule();
230 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); 213
231 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 214 SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
215
216 SceneSetupHelpers.AddRootAgent(myScene1, agent1Id);
217 ScenePresence childPresence = myScene2.GetScenePresence(agent1);
218
219 // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
220// Assert.That(childPresence, Is.Not.Null);
221// Assert.That(childPresence.IsChildAgent, Is.True);
232 } 222 }
233 223
234 // I'm commenting this test because it does not represent 224 // I'm commenting this test because it does not represent
@@ -333,63 +323,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 323 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
334 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 324 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
335 } 325 }
336 326
337 [Test] 327 public void fixNullPresence()
338 public void T030_TestAddAttachments()
339 {
340 TestHelper.InMethod();
341
342 ScenePresence presence = scene.GetScenePresence(agent1);
343
344 presence.AddAttachment(sog1);
345 presence.AddAttachment(sog2);
346 presence.AddAttachment(sog3);
347
348 Assert.That(presence.HasAttachments(), Is.True);
349 Assert.That(presence.ValidateAttachments(), Is.True);
350 }
351
352 [Test]
353 public void T031_RemoveAttachments()
354 {
355 TestHelper.InMethod();
356
357 ScenePresence presence = scene.GetScenePresence(agent1);
358 presence.RemoveAttachment(sog1);
359 presence.RemoveAttachment(sog2);
360 presence.RemoveAttachment(sog3);
361 Assert.That(presence.HasAttachments(), Is.False);
362 }
363
364 // I'm commenting this test because scene setup NEEDS InventoryService to
365 // be non-null
366 //[Test]
367 public void T032_CrossAttachments()
368 { 328 {
369 TestHelper.InMethod(); 329 string firstName = "testfirstname";
370
371 ScenePresence presence = scene.GetScenePresence(agent1);
372 ScenePresence presence2 = scene2.GetScenePresence(agent1);
373 presence2.AddAttachment(sog1);
374 presence2.AddAttachment(sog2);
375
376 ISharedRegionModule serialiser = new SerialiserModule();
377 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
378 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
379
380 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
381 330
382 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 331 AgentCircuitData agent = new AgentCircuitData();
383 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 332 agent.AgentID = agent1;
384 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 333 agent.firstname = firstName;
385 } 334 agent.lastname = "testlastname";
335 agent.SessionID = UUID.Zero;
336 agent.SecureSessionID = UUID.Zero;
337 agent.circuitcode = 123;
338 agent.BaseFolder = UUID.Zero;
339 agent.InventoryFolder = UUID.Zero;
340 agent.startpos = Vector3.Zero;
341 agent.CapsPath = GetRandomCapsObjectPath();
386 342
387 [TearDown] 343 acd1 = agent;
388 public void TearDown()
389 {
390 if (MainServer.Instance != null) MainServer.Instance.Stop();
391 } 344 }
392 345
393 public static string GetRandomCapsObjectPath() 346 public static string GetRandomCapsObjectPath()
394 { 347 {
395 UUID caps = UUID.Random(); 348 UUID caps = UUID.Random();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
new file mode 100644
index 0000000..abcce66
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -0,0 +1,70 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Scene presence tests
52 /// </summary>
53 [TestFixture]
54 public class SceneTests
55 {
56 /// <summary>
57 /// Very basic scene update test. Should become more elaborate with time.
58 /// </summary>
59 [Test]
60 public void TestUpdateScene()
61 {
62 TestHelper.InMethod();
63
64 Scene scene = SceneSetupHelpers.SetupScene();
65 scene.Update();
66
67 Assert.That(scene.Frame, Is.EqualTo(1));
68 }
69 }
70} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index cafe48a..8588f7f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index fe59d4f..8138bcc 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -34,7 +34,6 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenMetaverse.Assets; 38using OpenMetaverse.Assets;
40using OpenSim.Framework; 39using OpenSim.Framework;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 5e6124b..6b70865 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -28,7 +28,6 @@
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;