aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs234
1 files changed, 63 insertions, 171 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f444e51..a3f3d8f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -310,7 +310,7 @@ namespace OpenSim.Region.Framework.Scenes
310 private Thread HeartbeatThread; 310 private Thread HeartbeatThread;
311 private volatile bool shuttingdown; 311 private volatile bool shuttingdown;
312 312
313 private int m_lastUpdate = Environment.TickCount; 313 private int m_lastUpdate;
314 private bool m_firstHeartbeat = true; 314 private bool m_firstHeartbeat = true;
315 315
316 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; 316 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
@@ -387,6 +387,11 @@ namespace OpenSim.Region.Framework.Scenes
387 { 387 {
388 get { return StatsReporter.getLastReportedSimFPS(); } 388 get { return StatsReporter.getLastReportedSimFPS(); }
389 } 389 }
390
391 public float[] SimulatorStats
392 {
393 get { return StatsReporter.getLastReportedSimStats(); }
394 }
390 395
391 public string DefaultScriptEngine 396 public string DefaultScriptEngine
392 { 397 {
@@ -521,6 +526,7 @@ namespace OpenSim.Region.Framework.Scenes
521 m_regionHandle = m_regInfo.RegionHandle; 526 m_regionHandle = m_regInfo.RegionHandle;
522 m_regionName = m_regInfo.RegionName; 527 m_regionName = m_regInfo.RegionName;
523 m_datastore = m_regInfo.DataStore; 528 m_datastore = m_regInfo.DataStore;
529 m_lastUpdate = Util.EnvironmentTickCount();
524 530
525 m_physicalPrim = physicalPrim; 531 m_physicalPrim = physicalPrim;
526 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 532 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -618,7 +624,7 @@ namespace OpenSim.Region.Framework.Scenes
618 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); 624 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
619 m_persistAfter *= 10000000; 625 m_persistAfter *= 10000000;
620 626
621 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); 627 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
622 628
623 IConfig packetConfig = m_config.Configs["PacketPool"]; 629 IConfig packetConfig = m_config.Configs["PacketPool"];
624 if (packetConfig != null) 630 if (packetConfig != null)
@@ -730,6 +736,8 @@ namespace OpenSim.Region.Framework.Scenes
730 736
731 m_regInfo = regInfo; 737 m_regInfo = regInfo;
732 m_eventManager = new EventManager(); 738 m_eventManager = new EventManager();
739
740 m_lastUpdate = Util.EnvironmentTickCount();
733 } 741 }
734 742
735 #endregion 743 #endregion
@@ -1084,7 +1092,7 @@ namespace OpenSim.Region.Framework.Scenes
1084 HeartbeatThread.Abort(); 1092 HeartbeatThread.Abort();
1085 HeartbeatThread = null; 1093 HeartbeatThread = null;
1086 } 1094 }
1087 m_lastUpdate = Environment.TickCount; 1095 m_lastUpdate = Util.EnvironmentTickCount();
1088 1096
1089 HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false); 1097 HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false);
1090 } 1098 }
@@ -1125,7 +1133,7 @@ namespace OpenSim.Region.Framework.Scenes
1125 { 1133 {
1126 Update(); 1134 Update();
1127 1135
1128 m_lastUpdate = Environment.TickCount; 1136 m_lastUpdate = Util.EnvironmentTickCount();
1129 m_firstHeartbeat = false; 1137 m_firstHeartbeat = false;
1130 } 1138 }
1131 catch (ThreadAbortException) 1139 catch (ThreadAbortException)
@@ -1151,10 +1159,11 @@ namespace OpenSim.Region.Framework.Scenes
1151 while (!shuttingdown) 1159 while (!shuttingdown)
1152 { 1160 {
1153 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1161 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1154 physicsFPS = 0f; 1162 physicsFPS = 0f;
1155 1163
1156 maintc = otherMS = Environment.TickCount; 1164 maintc = Util.EnvironmentTickCount();
1157 int tmpFrameMS = maintc; 1165 int tmpFrameMS = maintc;
1166 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1158 1167
1159 // Increment the frame counter 1168 // Increment the frame counter
1160 ++m_frame; 1169 ++m_frame;
@@ -1174,74 +1183,65 @@ namespace OpenSim.Region.Framework.Scenes
1174 if (m_frame % m_update_presences == 0) 1183 if (m_frame % m_update_presences == 0)
1175 m_sceneGraph.UpdatePresences(); 1184 m_sceneGraph.UpdatePresences();
1176 1185
1177 int TempPhysicsMS2 = Environment.TickCount; 1186 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1178 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1187 if ((m_frame % m_update_physics == 0) && m_physics_enabled)
1179 m_sceneGraph.UpdatePreparePhysics(); 1188 m_sceneGraph.UpdatePreparePhysics();
1180 TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; 1189 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1181 physicsMS2 = TempPhysicsMS2;
1182 1190
1183 if (m_frame % m_update_entitymovement == 0) 1191 if (m_frame % m_update_entitymovement == 0)
1184 m_sceneGraph.UpdateScenePresenceMovement(); 1192 m_sceneGraph.UpdateScenePresenceMovement();
1185 1193
1186 int TempPhysicsMS = Environment.TickCount; 1194 int tmpPhysicsMS = Util.EnvironmentTickCount();
1187 if (m_frame % m_update_physics == 0) 1195 if (m_frame % m_update_physics == 0)
1188 { 1196 {
1189 if (m_physics_enabled) 1197 if (m_physics_enabled)
1190 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); 1198 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
1191 if (SynchronizeScene != null) 1199 if (SynchronizeScene != null)
1192 SynchronizeScene(this); 1200 SynchronizeScene(this);
1193 } 1201 }
1194 TempPhysicsMS = Environment.TickCount - TempPhysicsMS; 1202 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1195 physicsMS = TempPhysicsMS;
1196 1203
1197 // Delete temp-on-rez stuff 1204 // Delete temp-on-rez stuff
1198 if (m_frame % m_update_backup == 0) 1205 if (m_frame % m_update_backup == 0)
1199 { 1206 {
1200 int tozMS = Environment.TickCount; 1207 int tmpTempOnRezMS = Util.EnvironmentTickCount();
1201 CleanTempObjects(); 1208 CleanTempObjects();
1202 tozMS -= Environment.TickCount; 1209 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1203 tempOnRezMS = tozMS;
1204 } 1210 }
1205 1211
1206 if (RegionStatus != RegionStatus.SlaveScene) 1212 if (RegionStatus != RegionStatus.SlaveScene)
1207 { 1213 {
1208 if (m_frame % m_update_events == 0) 1214 if (m_frame % m_update_events == 0)
1209 { 1215 {
1210 int evMS = Environment.TickCount; 1216 int evMS = Util.EnvironmentTickCount();
1211 UpdateEvents(); 1217 UpdateEvents();
1212 evMS -= Environment.TickCount; 1218 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1213 eventMS = evMS;
1214 } 1219 }
1215 1220
1216 if (m_frame % m_update_backup == 0) 1221 if (m_frame % m_update_backup == 0)
1217 { 1222 {
1218 int backMS = Environment.TickCount; 1223 int backMS = Util.EnvironmentTickCount();
1219 UpdateStorageBackup(); 1224 UpdateStorageBackup();
1220 backMS -= Environment.TickCount; 1225 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1221 backupMS = backMS;
1222 } 1226 }
1223 1227
1224 if (m_frame % m_update_terrain == 0) 1228 if (m_frame % m_update_terrain == 0)
1225 { 1229 {
1226 int terMS = Environment.TickCount; 1230 int terMS = Util.EnvironmentTickCount();
1227 UpdateTerrain(); 1231 UpdateTerrain();
1228 terMS -= Environment.TickCount; 1232 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1229 terrainMS = terMS;
1230 } 1233 }
1231 1234
1232 if (m_frame % m_update_land == 0) 1235 if (m_frame % m_update_land == 0)
1233 { 1236 {
1234 int ldMS = Environment.TickCount; 1237 int ldMS = Util.EnvironmentTickCount();
1235 UpdateLand(); 1238 UpdateLand();
1236 ldMS -= Environment.TickCount; 1239 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1237 landMS = ldMS; 1240 }
1238 } 1241
1239 1242 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1240 int tickCount = Environment.TickCount; 1243 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1241 otherMS = tickCount - otherMS; 1244 lastCompletedFrame = Util.EnvironmentTickCount();
1242 tmpFrameMS -= tickCount;
1243 frameMS = tmpFrameMS;
1244 lastCompletedFrame = tickCount;
1245 1245
1246 // if (m_frame%m_update_avatars == 0) 1246 // if (m_frame%m_update_avatars == 0)
1247 // UpdateInWorldTime(); 1247 // UpdateInWorldTime();
@@ -1293,9 +1293,9 @@ namespace OpenSim.Region.Framework.Scenes
1293 finally 1293 finally
1294 { 1294 {
1295 m_lastupdate = DateTime.UtcNow; 1295 m_lastupdate = DateTime.UtcNow;
1296 } 1296 }
1297 1297
1298 maintc = Environment.TickCount - maintc; 1298 maintc = Util.EnvironmentTickCountSubtract(maintc);
1299 maintc = (int)(m_timespan * 1000) - maintc; 1299 maintc = (int)(m_timespan * 1000) - maintc;
1300 1300
1301 if ((maintc < (m_timespan * 1000)) && maintc > 0) 1301 if ((maintc < (m_timespan * 1000)) && maintc > 0)
@@ -1306,6 +1306,7 @@ namespace OpenSim.Region.Framework.Scenes
1306 } 1306 }
1307 } 1307 }
1308 1308
1309
1309 1310
1310 public void AddGroupTarget(SceneObjectGroup grp) 1311 public void AddGroupTarget(SceneObjectGroup grp)
1311 { 1312 {
@@ -2381,103 +2382,6 @@ namespace OpenSim.Region.Framework.Scenes
2381 return successYN; 2382 return successYN;
2382 } 2383 }
2383 2384
2384 /// <summary>
2385 /// Handle a scene object that is crossing into this region from another.
2386 /// NOTE: Unused as of 2009-02-09. Soon to be deleted.
2387 /// </summary>
2388 /// <param name="regionHandle"></param>
2389 /// <param name="primID"></param>
2390 /// <param name="objXMLData"></param>
2391 /// <param name="XMLMethod"></param>
2392 /// <returns></returns>
2393 public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod)
2394 {
2395 if (XMLMethod == 0)
2396 {
2397 m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
2398 SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
2399 if (sceneObject.IsAttachment)
2400 sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2401
2402 return AddSceneObject(sceneObject);
2403 }
2404 else if ((XMLMethod == 100) && m_allowScriptCrossings)
2405 {
2406 m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
2407
2408 XmlDocument doc = new XmlDocument();
2409 doc.LoadXml(objXMLData);
2410
2411 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
2412 if (rootL.Count == 1)
2413 {
2414 XmlNode rootNode = rootL[0];
2415 if (rootNode != null)
2416 {
2417 XmlNodeList partL = rootNode.ChildNodes;
2418
2419 foreach (XmlNode part in partL)
2420 {
2421 XmlNodeList nodeL = part.ChildNodes;
2422
2423 switch (part.Name)
2424 {
2425 case "Assemblies":
2426 foreach (XmlNode asm in nodeL)
2427 {
2428 string fn = asm.Attributes.GetNamedItem("Filename").Value;
2429
2430 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
2431 string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
2432 path = Path.Combine(path, fn);
2433
2434 if (!File.Exists(path))
2435 {
2436 FileStream fs = File.Create(path);
2437 fs.Write(filedata, 0, filedata.Length);
2438 fs.Close();
2439 }
2440 }
2441 break;
2442 case "ScriptStates":
2443 foreach (XmlNode st in nodeL)
2444 {
2445 string id = st.Attributes.GetNamedItem("UUID").Value;
2446 UUID uuid = new UUID(id);
2447 XmlNode state = st.ChildNodes[0];
2448
2449 XmlDocument sdoc = new XmlDocument();
2450 XmlNode sxmlnode = sdoc.CreateNode(
2451 XmlNodeType.XmlDeclaration,
2452 "", "");
2453 sdoc.AppendChild(sxmlnode);
2454
2455 XmlNode newnode = sdoc.ImportNode(state, true);
2456 sdoc.AppendChild(newnode);
2457
2458 string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
2459 spath = Path.Combine(spath, uuid.ToString());
2460 FileStream sfs = File.Create(spath + ".state");
2461 ASCIIEncoding enc = new ASCIIEncoding();
2462 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
2463 sfs.Write(buf, 0, buf.Length);
2464 sfs.Close();
2465 }
2466 break;
2467 }
2468 }
2469 }
2470 }
2471
2472 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
2473 RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
2474
2475 return true;
2476 }
2477
2478 return true;
2479 }
2480
2481 public bool IncomingCreateObject(ISceneObject sog) 2385 public bool IncomingCreateObject(ISceneObject sog)
2482 { 2386 {
2483 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2387 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
@@ -2677,9 +2581,9 @@ namespace OpenSim.Region.Framework.Scenes
2677 sp.IsChildAgent = false; 2581 sp.IsChildAgent = false;
2678 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2582 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
2679 } 2583 }
2680 } 2584 }
2681 2585
2682 m_LastLogin = Environment.TickCount; 2586 m_LastLogin = Util.EnvironmentTickCount();
2683 EventManager.TriggerOnNewClient(client); 2587 EventManager.TriggerOnNewClient(client);
2684 } 2588 }
2685 2589
@@ -3350,7 +3254,6 @@ namespace OpenSim.Region.Framework.Scenes
3350 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3254 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3351 //m_eventManager.OnRegionUp += OtherRegionUp; 3255 //m_eventManager.OnRegionUp += OtherRegionUp;
3352 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3256 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3353 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3354 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3257 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3355 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3258 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3356 m_sceneGridService.KiPrimitive += SendKillObject; 3259 m_sceneGridService.KiPrimitive += SendKillObject;
@@ -3374,7 +3277,6 @@ namespace OpenSim.Region.Framework.Scenes
3374 m_sceneGridService.KiPrimitive -= SendKillObject; 3277 m_sceneGridService.KiPrimitive -= SendKillObject;
3375 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3278 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3376 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3279 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3377 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3378 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3280 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3379 //m_eventManager.OnRegionUp -= OtherRegionUp; 3281 //m_eventManager.OnRegionUp -= OtherRegionUp;
3380 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3282 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
@@ -4492,16 +4394,6 @@ namespace OpenSim.Region.Framework.Scenes
4492 4394
4493 #endregion 4395 #endregion
4494 4396
4495 #region Avatar Appearance Default
4496
4497 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
4498 {
4499 visualParams = AvatarAppearance.GetDefaultVisualParams();
4500 wearables = AvatarWearable.DefaultWearables;
4501 }
4502
4503 #endregion
4504
4505 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4397 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4506 { 4398 {
4507 ulong handle = 0; 4399 ulong handle = 0;
@@ -4758,16 +4650,16 @@ namespace OpenSim.Region.Framework.Scenes
4758 // 3 = We have seen a new user enter within the past 4 minutes 4650 // 3 = We have seen a new user enter within the past 4 minutes
4759 // which can be seen as positive confirmation of sim health 4651 // which can be seen as positive confirmation of sim health
4760 // 4652 //
4761 int health=1; // Start at 1, means we're up 4653 int health=1; // Start at 1, means we're up
4762 4654
4763 if ((Environment.TickCount - m_lastUpdate) < 1000) 4655 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000)
4764 health+=1; 4656 health+=1;
4765 else 4657 else
4766 return health; 4658 return health;
4767 4659
4768 // A login in the last 4 mins? We can't be doing too badly 4660 // A login in the last 4 mins? We can't be doing too badly
4769 // 4661 //
4770 if ((Environment.TickCount - m_LastLogin) < 240000) 4662 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000)
4771 health++; 4663 health++;
4772 else 4664 else
4773 return health; 4665 return health;
@@ -4963,9 +4855,9 @@ namespace OpenSim.Region.Framework.Scenes
4963 private void CheckHeartbeat() 4855 private void CheckHeartbeat()
4964 { 4856 {
4965 if (m_firstHeartbeat) 4857 if (m_firstHeartbeat)
4966 return; 4858 return;
4967 4859
4968 if (System.Environment.TickCount - m_lastUpdate > 2000) 4860 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4969 StartTimer(); 4861 StartTimer();
4970 } 4862 }
4971 } 4863 }