diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 235 |
1 files changed, 111 insertions, 124 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c5bb2b2..b288c8a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -896,6 +896,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | 896 | ||
897 | if (dm != null) | 897 | if (dm != null) |
898 | m_eventManager.OnPermissionError += dm.SendAlertToUser; | 898 | m_eventManager.OnPermissionError += dm.SendAlertToUser; |
899 | |||
900 | m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; | ||
899 | } | 901 | } |
900 | 902 | ||
901 | public override string GetSimulatorVersion() | 903 | public override string GetSimulatorVersion() |
@@ -1198,87 +1200,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1198 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1200 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1199 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1201 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1200 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); | 1202 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); |
1201 | |||
1202 | // Shoving this in here for now, because we have the needed | ||
1203 | // interfaces at this point | ||
1204 | // | ||
1205 | // TODO: Find a better place for this | ||
1206 | // | ||
1207 | while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) | ||
1208 | { | ||
1209 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName); | ||
1210 | List<char> excluded = new List<char>(new char[1]{' '}); | ||
1211 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); | ||
1212 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); | ||
1213 | |||
1214 | UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); | ||
1215 | |||
1216 | if (account == null) | ||
1217 | { | ||
1218 | // Create a new account | ||
1219 | account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); | ||
1220 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
1221 | { | ||
1222 | account.ServiceURLs = new Dictionary<string, object>(); | ||
1223 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
1224 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
1225 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
1226 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
1227 | } | ||
1228 | |||
1229 | if (UserAccountService.StoreUserAccount(account)) | ||
1230 | { | ||
1231 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
1232 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
1233 | |||
1234 | account.Email = email; | ||
1235 | UserAccountService.StoreUserAccount(account); | ||
1236 | |||
1237 | bool success = false; | ||
1238 | success = AuthenticationService.SetPassword(account.PrincipalID, password); | ||
1239 | if (!success) | ||
1240 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", | ||
1241 | first, last); | ||
1242 | |||
1243 | GridRegion home = null; | ||
1244 | if (GridService != null) | ||
1245 | { | ||
1246 | List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero); | ||
1247 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
1248 | home = defaultRegions[0]; | ||
1249 | |||
1250 | if (GridUserService != null && home != null) | ||
1251 | GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1252 | else | ||
1253 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | ||
1254 | first, last); | ||
1255 | |||
1256 | } | ||
1257 | else | ||
1258 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
1259 | first, last); | ||
1260 | |||
1261 | if (InventoryService != null) | ||
1262 | success = InventoryService.CreateUserInventory(account.PrincipalID); | ||
1263 | if (!success) | ||
1264 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | ||
1265 | first, last); | ||
1266 | |||
1267 | |||
1268 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); | ||
1269 | |||
1270 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1271 | m_regInfo.EstateSettings.Save(); | ||
1272 | } | ||
1273 | else | ||
1274 | m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); | ||
1275 | } | ||
1276 | else | ||
1277 | { | ||
1278 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1279 | m_regInfo.EstateSettings.Save(); | ||
1280 | } | ||
1281 | } | ||
1282 | } | 1203 | } |
1283 | 1204 | ||
1284 | #endregion | 1205 | #endregion |
@@ -1382,28 +1303,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1382 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | 1303 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); |
1383 | } | 1304 | } |
1384 | 1305 | ||
1385 | if (RegionStatus != RegionStatus.SlaveScene) | 1306 | if (Frame % m_update_events == 0) |
1386 | { | 1307 | { |
1387 | if (Frame % m_update_events == 0) | 1308 | int evMS = Util.EnvironmentTickCount(); |
1388 | { | 1309 | UpdateEvents(); |
1389 | int evMS = Util.EnvironmentTickCount(); | 1310 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1390 | UpdateEvents(); | 1311 | } |
1391 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | ||
1392 | } | ||
1393 | |||
1394 | if (Frame % m_update_backup == 0) | ||
1395 | { | ||
1396 | int backMS = Util.EnvironmentTickCount(); | ||
1397 | UpdateStorageBackup(); | ||
1398 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | ||
1399 | } | ||
1400 | |||
1401 | if (Frame % m_update_terrain == 0) | ||
1402 | { | ||
1403 | int terMS = Util.EnvironmentTickCount(); | ||
1404 | UpdateTerrain(); | ||
1405 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | ||
1406 | } | ||
1407 | 1312 | ||
1408 | // if (Frame % m_update_land == 0) | 1313 | // if (Frame % m_update_land == 0) |
1409 | // { | 1314 | // { |
@@ -1412,26 +1317,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1412 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1317 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1413 | // } | 1318 | // } |
1414 | 1319 | ||
1415 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1320 | if (Frame % m_update_backup == 0) |
1416 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1321 | { |
1417 | lastCompletedFrame = Util.EnvironmentTickCount(); | 1322 | int backMS = Util.EnvironmentTickCount(); |
1418 | 1323 | UpdateStorageBackup(); | |
1419 | // if (Frame%m_update_avatars == 0) | 1324 | backupMS = Util.EnvironmentTickCountSubtract(backMS); |
1420 | // UpdateInWorldTime(); | 1325 | } |
1421 | StatsReporter.AddPhysicsFPS(physicsFPS); | 1326 | |
1422 | StatsReporter.AddTimeDilation(TimeDilation); | 1327 | if (Frame % m_update_terrain == 0) |
1423 | StatsReporter.AddFPS(1); | 1328 | { |
1424 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | 1329 | int terMS = Util.EnvironmentTickCount(); |
1425 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | 1330 | UpdateTerrain(); |
1426 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | 1331 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1427 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1428 | StatsReporter.addFrameMS(frameMS); | ||
1429 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1430 | StatsReporter.addOtherMS(otherMS); | ||
1431 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1432 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1433 | } | 1332 | } |
1434 | 1333 | ||
1334 | //if (Frame % m_update_land == 0) | ||
1335 | //{ | ||
1336 | // int ldMS = Util.EnvironmentTickCount(); | ||
1337 | // UpdateLand(); | ||
1338 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1339 | //} | ||
1340 | |||
1341 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | ||
1342 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1343 | lastCompletedFrame = Util.EnvironmentTickCount(); | ||
1344 | |||
1345 | // if (Frame%m_update_avatars == 0) | ||
1346 | // UpdateInWorldTime(); | ||
1347 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1348 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1349 | StatsReporter.AddFPS(1); | ||
1350 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1351 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1352 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1353 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1354 | StatsReporter.addFrameMS(frameMS); | ||
1355 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1356 | StatsReporter.addOtherMS(otherMS); | ||
1357 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1358 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1359 | |||
1435 | if (LoginsDisabled && Frame == 20) | 1360 | if (LoginsDisabled && Frame == 20) |
1436 | { | 1361 | { |
1437 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, | 1362 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, |
@@ -2603,9 +2528,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2603 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2528 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2604 | 2529 | ||
2605 | if (AttachmentsModule != null) | 2530 | if (AttachmentsModule != null) |
2606 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2531 | AttachmentsModule.AttachObject(sp, grp, 0, false); |
2607 | |||
2608 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2609 | } | 2532 | } |
2610 | else | 2533 | else |
2611 | { | 2534 | { |
@@ -5477,7 +5400,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5477 | return true; | 5400 | return true; |
5478 | } | 5401 | } |
5479 | 5402 | ||
5480 | public void StartTimerWatchdog() | 5403 | public void StartTimerWatchdog() |
5481 | { | 5404 | { |
5482 | m_timerWatchdog.Interval = 1000; | 5405 | m_timerWatchdog.Interval = 1000; |
5483 | m_timerWatchdog.Elapsed += TimerWatchdog; | 5406 | m_timerWatchdog.Elapsed += TimerWatchdog; |
@@ -5488,6 +5411,70 @@ namespace OpenSim.Region.Framework.Scenes | |||
5488 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | 5411 | public void TimerWatchdog(object sender, ElapsedEventArgs e) |
5489 | { | 5412 | { |
5490 | CheckHeartbeat(); | 5413 | CheckHeartbeat(); |
5414 | } | ||
5415 | |||
5416 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | ||
5417 | /// autopilot that moves an avatar to a sit target!. | ||
5418 | /// </summary> | ||
5419 | /// <remarks> | ||
5420 | /// This is not intended as a permament location for this method. | ||
5421 | /// </remarks> | ||
5422 | /// <param name="presence"></param> | ||
5423 | private void HandleOnSignificantClientMovement(ScenePresence presence) | ||
5424 | { | ||
5425 | if (presence.MovingToTarget) | ||
5426 | { | ||
5427 | double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
5428 | // m_log.DebugFormat( | ||
5429 | // "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}", | ||
5430 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); | ||
5431 | |||
5432 | // Check the error term of the current position in relation to the target position | ||
5433 | if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) | ||
5434 | { | ||
5435 | // We are close enough to the target | ||
5436 | // m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name); | ||
5437 | |||
5438 | presence.Velocity = Vector3.Zero; | ||
5439 | presence.AbsolutePosition = presence.MoveToPositionTarget; | ||
5440 | presence.ResetMoveToTarget(); | ||
5441 | |||
5442 | if (presence.PhysicsActor.Flying) | ||
5443 | { | ||
5444 | // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot | ||
5445 | // the target if flying. | ||
5446 | // We really need to be more subtle (slow the avatar as it approaches the target) or at | ||
5447 | // least be able to set collision status once, rather than 5 times to give it enough | ||
5448 | // weighting so that that PhysicsActor thinks it really is colliding. | ||
5449 | for (int i = 0; i < 5; i++) | ||
5450 | presence.PhysicsActor.IsColliding = true; | ||
5451 | |||
5452 | if (presence.LandAtTarget) | ||
5453 | presence.PhysicsActor.Flying = false; | ||
5454 | |||
5455 | // Vector3 targetPos = presence.MoveToPositionTarget; | ||
5456 | // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; | ||
5457 | // if (targetPos.Z - terrainHeight < 0.2) | ||
5458 | // { | ||
5459 | // presence.PhysicsActor.Flying = false; | ||
5460 | // } | ||
5461 | } | ||
5462 | |||
5463 | // m_log.DebugFormat( | ||
5464 | // "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}", | ||
5465 | // presence.AgentControlFlags, presence.MovementFlag, presence.Name); | ||
5466 | } | ||
5467 | else | ||
5468 | { | ||
5469 | // m_log.DebugFormat( | ||
5470 | // "[SCENE]: Updating npc {0} at {1} for next movement to {2}", | ||
5471 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
5472 | |||
5473 | Vector3 agent_control_v3 = new Vector3(); | ||
5474 | presence.HandleMoveToTargetUpdate(ref agent_control_v3); | ||
5475 | presence.AddNewMovement(agent_control_v3); | ||
5476 | } | ||
5477 | } | ||
5491 | } | 5478 | } |
5492 | } | 5479 | } |
5493 | } | 5480 | } |