aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs234
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs190
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs60
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs26
11 files changed, 166 insertions, 504 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 2c906a2..89a45da 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -185,19 +185,11 @@ namespace OpenSim.Region.Framework.Interfaces
185 List<UUID> GetInventoryList(); 185 List<UUID> GetInventoryList();
186 186
187 /// <summary> 187 /// <summary>
188 /// Get the names of the assemblies associated with scripts in this inventory.
189 /// </summary>
190 /// <returns></returns>
191 string[] GetScriptAssemblies();
192
193 /// <summary>
194 /// Get the xml representing the saved states of scripts in this inventory. 188 /// Get the xml representing the saved states of scripts in this inventory.
195 /// </summary> 189 /// </summary>
196 /// <returns> 190 /// <returns>
197 /// A <see cref="Dictionary`2"/> 191 /// A <see cref="Dictionary`2"/>
198 /// </returns> 192 /// </returns>
199 Dictionary<UUID, string> GetScriptStates(); 193 Dictionary<UUID, string> GetScriptStates();
200
201 bool CanBeDeleted();
202 } 194 }
203} 195}
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 10835b9..f11e571 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -34,9 +34,8 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 34 {
35 string ScriptEngineName { get; } 35 string ScriptEngineName { get; }
36 36
37 string GetAssemblyName(UUID itemID);
38 string GetXMLState(UUID itemID); 37 string GetXMLState(UUID itemID);
39 bool CanBeDeleted(UUID itemID); 38 void SetXMLState(UUID itemID, string xml);
40 39
41 bool PostScriptEvent(UUID itemID, string name, Object[] args); 40 bool PostScriptEvent(UUID itemID, string name, Object[] args);
42 bool PostObjectEvent(UUID itemID, string name, Object[] args); 41 bool PostObjectEvent(UUID itemID, string name, Object[] args);
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 5b571c7..9a7863b 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -131,11 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 if (left > 0) 131 if (left > 0)
132 { 132 {
133 x = m_inventoryDeletes.Dequeue(); 133 x = m_inventoryDeletes.Dequeue();
134 if (!x.objectGroup.CanBeDeleted())
135 {
136 m_inventoryDeletes.Enqueue(x);
137 return true;
138 }
139 134
140 m_log.DebugFormat( 135 m_log.DebugFormat(
141 "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); 136 "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left);
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 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 76c6cab..3892769 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes
85 /// <summary> 85 /// <summary>
86 /// A Prim will arrive shortly 86 /// A Prim will arrive shortly
87 /// </summary> 87 /// </summary>
88 public event ExpectPrimDelegate OnExpectPrim;
89 public event CloseAgentConnection OnCloseAgentConnection; 88 public event CloseAgentConnection OnCloseAgentConnection;
90 89
91 /// <summary> 90 /// <summary>
@@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
116 115
117 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; 116 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
118 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; 117 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 118 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 119 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
122 //private RegionUp handlerRegionUp = null; // OnRegionUp; 120 //private RegionUp handlerRegionUp = null; // OnRegionUp;
@@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes
147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 145 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 146 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
149 { 147 {
150 //m_interregionCommsOut = comms_out;
151
152 //m_regionInfo = regionInfos;
153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
155
156 //if (regionCommsHost != null)
157 //{
158 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
159
160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
162 // regionCommsHost.OnExpectUser += NewUserConnection;
163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
165 // regionCommsHost.OnRegionUp += newRegionUp;
166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
168 // regionCommsHost.OnGetLandData += FetchLandData;
169 //}
170 //else
171 //{
172 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
173 //}
174 } 148 }
175 149
176 /// <summary> 150 /// <summary>
@@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes
179 /// </summary> 153 /// </summary>
180 public void Close() 154 public void Close()
181 { 155 {
182
183 //if (regionCommsHost != null)
184 //{
185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
187 // regionCommsHost.OnRegionUp -= newRegionUp;
188 // regionCommsHost.OnExpectUser -= NewUserConnection;
189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
193
194 // try
195 // {
196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
197 // }
198 // catch (Exception e)
199 // {
200 // m_log.ErrorFormat(
201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
202 // m_regionInfo.RegionName, e);
203 // }
204
205 // regionCommsHost = null;
206 //}
207 } 156 }
208 157
209 #region CommsManager Event handlers 158 #region CommsManager Event handlers
@@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes
263 } 212 }
264 } 213 }
265 214
266 /// <summary>
267 /// We have a new prim from a neighbor
268 /// </summary>
269 /// <param name="primID">unique ID for the primative</param>
270 /// <param name="objXMLData">XML2 encoded data of the primative</param>
271 /// <param name="XMLMethod">An Int that represents the version of the XMLMethod</param>
272 /// <returns>True if the prim was accepted, false if it was not</returns>
273 protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod)
274 {
275 handlerExpectPrim = OnExpectPrim;
276 if (handlerExpectPrim != null)
277 {
278 return handlerExpectPrim(primID, objXMLData, XMLMethod);
279 }
280 else
281 {
282 return false;
283 }
284
285 }
286
287 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) 215 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
288 { 216 {
289 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; 217 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 3cec77f..5a06bdb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
309 309
310 public string GetStateSnapshot() 310 public string GetStateSnapshot()
311 { 311 {
312 //m_log.Debug(" >>> GetStateSnapshot <<<");
313
314 List<string> assemblies = new List<string>();
315 Dictionary<UUID, string> states = new Dictionary<UUID, string>(); 312 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
316 313
317 foreach (SceneObjectPart part in m_parts.Values) 314 foreach (SceneObjectPart part in m_parts.Values)
318 { 315 {
319 foreach (string a in part.Inventory.GetScriptAssemblies())
320 {
321 if (a != "" && !assemblies.Contains(a))
322 assemblies.Add(a);
323 }
324
325 foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates()) 316 foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates())
326 {
327 states[s.Key] = s.Value; 317 states[s.Key] = s.Value;
328 }
329 } 318 }
330 319
331 if (states.Count < 1 || assemblies.Count < 1) 320 if (states.Count < 1)
332 return ""; 321 return "";
333 322
334 XmlDocument xmldoc = new XmlDocument(); 323 XmlDocument xmldoc = new XmlDocument();
@@ -342,104 +331,49 @@ namespace OpenSim.Region.Framework.Scenes
342 331
343 xmldoc.AppendChild(rootElement); 332 xmldoc.AppendChild(rootElement);
344 333
345 XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
346 "");
347 334
348 rootElement.AppendChild(wrapper); 335 XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
349
350 foreach (string assembly in assemblies)
351 {
352 string fn = Path.GetFileName(assembly);
353 if (fn == String.Empty)
354 continue;
355
356 String filedata = String.Empty;
357
358 if (File.Exists(assembly+".text"))
359 {
360 FileInfo tfi = new FileInfo(assembly+".text");
361
362 if (tfi == null)
363 continue;
364
365 Byte[] tdata = new Byte[tfi.Length];
366
367 try
368 {
369 FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read);
370 tfs.Read(tdata, 0, tdata.Length);
371 tfs.Close();
372 }
373 catch (Exception e)
374 {
375 m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message);
376 }
377
378 filedata = new System.Text.ASCIIEncoding().GetString(tdata);
379 }
380 else
381 {
382 FileInfo fi = new FileInfo(assembly);
383
384 if (fi == null)
385 continue;
386
387 Byte[] data = new Byte[fi.Length];
388
389 try
390 {
391 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
392 fs.Read(data, 0, data.Length);
393 fs.Close();
394 }
395 catch (Exception e)
396 {
397 m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
398 }
399
400 filedata = System.Convert.ToBase64String(data);
401 }
402 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
403 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
404 assemblyName.Value = fn;
405 assemblyData.Attributes.Append(assemblyName);
406
407 assemblyData.InnerText = filedata;
408
409 wrapper.AppendChild(assemblyData);
410 }
411
412 wrapper = xmldoc.CreateElement("", "ScriptStates",
413 ""); 336 "");
414 337
415 rootElement.AppendChild(wrapper); 338 rootElement.AppendChild(wrapper);
416 339
417 foreach (KeyValuePair<UUID, string> state in states) 340 foreach (KeyValuePair<UUID, string> state in states)
418 { 341 {
419 XmlElement stateData = xmldoc.CreateElement("", "State", "");
420
421 XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
422 stateID.Value = state.Key.ToString();
423 stateData.Attributes.Append(stateID);
424
425 XmlDocument sdoc = new XmlDocument(); 342 XmlDocument sdoc = new XmlDocument();
426 sdoc.LoadXml(state.Value); 343 sdoc.LoadXml(state.Value);
427 XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); 344 XmlNodeList rootL = sdoc.GetElementsByTagName("State");
428 XmlNode rootNode = rootL[0]; 345 XmlNode rootNode = rootL[0];
429 346
430 XmlNode newNode = xmldoc.ImportNode(rootNode, true); 347 XmlNode newNode = xmldoc.ImportNode(rootNode, true);
431 stateData.AppendChild(newNode); 348 wrapper.AppendChild(newNode);
432 wrapper.AppendChild(stateData);
433 } 349 }
434 350
435 return xmldoc.InnerXml; 351 return xmldoc.InnerXml;
436 } 352 }
437 353
438 public void SetState(string objXMLData, UUID RegionID) 354 public void SetState(string objXMLData, IScene ins)
439 { 355 {
356 if (!(ins is Scene))
357 return;
358
359 Scene s = (Scene)ins;
360
440 if (objXMLData == String.Empty) 361 if (objXMLData == String.Empty)
441 return; 362 return;
442 363
364 IScriptModule scriptModule = null;
365
366 foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>())
367 {
368 if (sm.ScriptEngineName == s.DefaultScriptEngine)
369 scriptModule = sm;
370 else if (scriptModule == null)
371 scriptModule = sm;
372 }
373
374 if (scriptModule == null)
375 return;
376
443 XmlDocument doc = new XmlDocument(); 377 XmlDocument doc = new XmlDocument();
444 try 378 try
445 { 379 {
@@ -457,69 +391,23 @@ namespace OpenSim.Region.Framework.Scenes
457 } 391 }
458 392
459 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); 393 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
460 if (rootL.Count == 1) 394 if (rootL.Count != 1)
395 return;
396
397 XmlElement rootE = (XmlElement)rootL[0];
398
399 XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates");
400 if (dataL.Count != 1)
401 return;
402
403 XmlElement dataE = (XmlElement)dataL[0];
404
405 foreach (XmlNode n in dataE.ChildNodes)
461 { 406 {
462 XmlNode rootNode = rootL[0]; 407 XmlElement stateE = (XmlElement)n;
463 if (rootNode != null) 408 UUID itemID = new UUID(stateE.GetAttribute("UUID"));
464 { 409
465 XmlNodeList partL = rootNode.ChildNodes; 410 scriptModule.SetXMLState(itemID, n.OuterXml);
466
467 foreach (XmlNode part in partL)
468 {
469 XmlNodeList nodeL = part.ChildNodes;
470
471 switch (part.Name)
472 {
473 case "Assemblies":
474 foreach (XmlNode asm in nodeL)
475 {
476 string fn = asm.Attributes.GetNamedItem("Filename").Value;
477
478 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
479 string path = Path.Combine("ScriptEngines", RegionID.ToString());
480 path = Path.Combine(path, fn);
481
482 if (!File.Exists(path))
483 {
484 FileStream fs = File.Create(path);
485 fs.Write(filedata, 0, filedata.Length);
486 fs.Close();
487
488 Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText);
489 fs = File.Create(path+".text");
490 fs.Write(textbytes, 0, textbytes.Length);
491 fs.Close();
492 }
493 }
494 break;
495 case "ScriptStates":
496 foreach (XmlNode st in nodeL)
497 {
498 string id = st.Attributes.GetNamedItem("UUID").Value;
499 UUID uuid = new UUID(id);
500 XmlNode state = st.ChildNodes[0];
501
502 XmlDocument sdoc = new XmlDocument();
503 XmlNode sxmlnode = sdoc.CreateNode(
504 XmlNodeType.XmlDeclaration,
505 "", "");
506 sdoc.AppendChild(sxmlnode);
507
508 XmlNode newnode = sdoc.ImportNode(state, true);
509 sdoc.AppendChild(newnode);
510
511 string spath = Path.Combine("ScriptEngines", RegionID.ToString());
512 spath = Path.Combine(spath, uuid.ToString());
513 FileStream sfs = File.Create(spath + ".state");
514 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
515 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
516 sfs.Write(buf, 0, buf.Length);
517 sfs.Close();
518 }
519 break;
520 }
521 }
522 }
523 } 411 }
524 } 412 }
525 } 413 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index bcc9b37..7359011 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1199,6 +1199,7 @@ namespace OpenSim.Region.Framework.Scenes
1199 1199
1200 if (!silent) 1200 if (!silent)
1201 { 1201 {
1202 part.UpdateFlag = 0;
1202 if (part == m_rootPart) 1203 if (part == m_rootPart)
1203 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId); 1204 avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalId);
1204 } 1205 }
@@ -3341,17 +3342,6 @@ namespace OpenSim.Region.Framework.Scenes
3341 } 3342 }
3342 #endregion 3343 #endregion
3343 3344
3344 public bool CanBeDeleted()
3345 {
3346 foreach (SceneObjectPart part in Children.Values)
3347 {
3348 if (!part.CanBeDeleted())
3349 return false;
3350 }
3351
3352 return true;
3353 }
3354
3355 public double GetUpdatePriority(IClientAPI client) 3345 public double GetUpdatePriority(IClientAPI client)
3356 { 3346 {
3357 switch (Scene.UpdatePrioritizationScheme) 3347 switch (Scene.UpdatePrioritizationScheme)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6f1b458..b6916f2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3797,10 +3797,5 @@ namespace OpenSim.Region.Framework.Scenes
3797 3797
3798 Inventory.ApplyNextOwnerPermissions(); 3798 Inventory.ApplyNextOwnerPermissions();
3799 } 3799 }
3800
3801 public bool CanBeDeleted()
3802 {
3803 return Inventory.CanBeDeleted();
3804 }
3805 } 3800 }
3806} 3801}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index f4ca877..7a0d7b7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes
857 return ret; 857 return ret;
858 } 858 }
859 859
860 public string[] GetScriptAssemblies()
861 {
862 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
863
864 List<string> ret = new List<string>();
865 if (engines == null) // No engine at all
866 return new string[0];
867
868 foreach (TaskInventoryItem item in m_items.Values)
869 {
870 if (item.InvType == (int)InventoryType.LSL)
871 {
872 foreach (IScriptModule e in engines)
873 {
874 if (e != null)
875 {
876 string n = e.GetAssemblyName(item.ItemID);
877 if (n != String.Empty)
878 {
879 if (!ret.Contains(n))
880 ret.Add(n);
881 break;
882 }
883 }
884 }
885 }
886 }
887 return ret.ToArray();
888 }
889
890 public Dictionary<UUID, string> GetScriptStates() 860 public Dictionary<UUID, string> GetScriptStates()
891 { 861 {
892 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 862 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -916,30 +886,5 @@ namespace OpenSim.Region.Framework.Scenes
916 } 886 }
917 return ret; 887 return ret;
918 } 888 }
919
920 public bool CanBeDeleted()
921 {
922 if (!ContainsScripts())
923 return true;
924
925 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
926
927 if (engines == null) // No engine at all
928 return true;
929
930 foreach (TaskInventoryItem item in m_items.Values)
931 {
932 if (item.InvType == (int)InventoryType.LSL)
933 {
934 foreach (IScriptModule e in engines)
935 {
936 if (!e.CanBeDeleted(item.ItemID))
937 return false;
938 }
939 }
940 }
941
942 return true;
943 }
944 } 889 }
945} 890}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5604e3d..bcad335 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -755,13 +755,37 @@ namespace OpenSim.Region.Framework.Scenes
755 /// </summary> 755 /// </summary>
756 public void SendPrimUpdates() 756 public void SendPrimUpdates()
757 { 757 {
758 m_perfMonMS = Environment.TickCount; 758 m_perfMonMS = EnvironmentTickCount();
759 759
760 m_sceneViewer.SendPrimUpdates(); 760 m_sceneViewer.SendPrimUpdates();
761 761
762 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 762 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
763 } 763 }
764 764
765 /// <summary>
766 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
767 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
768 /// for the callers.
769 /// This trims it to a 12 day interval so don't let your frame time get too long.
770 /// </summary>
771 /// <returns></returns>
772 const Int32 EnvironmentTickCountMask = 0x3fffffff;
773 private static Int32 EnvironmentTickCount() {
774 return Environment.TickCount & EnvironmentTickCountMask;
775 }
776
777 /// <summary>
778 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
779 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by
780 /// 'EnvironmentTickCount()') and accounts for any wrapping.
781 /// </summary>
782 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
783 private static Int32 EnvironmentTickCountSubtract(Int32 prevValue) {
784 Int32 diff = EnvironmentTickCount() - prevValue;
785 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
786 }
787
788
765 #region Status Methods 789 #region Status Methods
766 790
767 /// <summary> 791 /// <summary>
@@ -1148,7 +1172,7 @@ namespace OpenSim.Region.Framework.Scenes
1148 // return; 1172 // return;
1149 //} 1173 //}
1150 1174
1151 m_perfMonMS = Environment.TickCount; 1175 m_perfMonMS = EnvironmentTickCount();
1152 1176
1153 ++m_movementUpdateCount; 1177 ++m_movementUpdateCount;
1154 if (m_movementUpdateCount < 1) 1178 if (m_movementUpdateCount < 1)
@@ -1464,7 +1488,7 @@ namespace OpenSim.Region.Framework.Scenes
1464 1488
1465 m_scene.EventManager.TriggerOnClientMovement(this); 1489 m_scene.EventManager.TriggerOnClientMovement(this);
1466 1490
1467 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 1491 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
1468 } 1492 }
1469 1493
1470 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) 1494 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
@@ -1924,7 +1948,7 @@ namespace OpenSim.Region.Framework.Scenes
1924 return; 1948 return;
1925 } 1949 }
1926 1950
1927 m_perfMonMS = Environment.TickCount; 1951 m_perfMonMS = EnvironmentTickCount();
1928 1952
1929 Rotation = rotation; 1953 Rotation = rotation;
1930 Vector3 direc = vec * rotation; 1954 Vector3 direc = vec * rotation;
@@ -1966,7 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes
1966 // TODO: Add the force instead of only setting it to support multiple forces per frame? 1990 // TODO: Add the force instead of only setting it to support multiple forces per frame?
1967 m_forceToApply = direc; 1991 m_forceToApply = direc;
1968 1992
1969 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 1993 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
1970 } 1994 }
1971 1995
1972 #endregion 1996 #endregion
@@ -2032,7 +2056,7 @@ namespace OpenSim.Region.Framework.Scenes
2032 // server. 2056 // server.
2033 if (remoteClient.IsActive) 2057 if (remoteClient.IsActive)
2034 { 2058 {
2035 m_perfMonMS = Environment.TickCount; 2059 m_perfMonMS = EnvironmentTickCount();
2036 2060
2037 PhysicsActor actor = m_physicsActor; 2061 PhysicsActor actor = m_physicsActor;
2038 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; 2062 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero;
@@ -2045,7 +2069,7 @@ namespace OpenSim.Region.Framework.Scenes
2045 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, 2069 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2046 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); 2070 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient)));
2047 2071
2048 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2072 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2049 m_scene.StatsReporter.AddAgentUpdates(1); 2073 m_scene.StatsReporter.AddAgentUpdates(1);
2050 } 2074 }
2051 } 2075 }
@@ -2055,11 +2079,11 @@ namespace OpenSim.Region.Framework.Scenes
2055 /// </summary> 2079 /// </summary>
2056 public void SendTerseUpdateToAllClients() 2080 public void SendTerseUpdateToAllClients()
2057 { 2081 {
2058 m_perfMonMS = Environment.TickCount; 2082 m_perfMonMS = EnvironmentTickCount();
2059 2083
2060 m_scene.ForEachClient(SendTerseUpdateToClient); 2084 m_scene.ForEachClient(SendTerseUpdateToClient);
2061 2085
2062 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2086 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2063 } 2087 }
2064 2088
2065 public void SendCoarseLocations() 2089 public void SendCoarseLocations()
@@ -2079,7 +2103,7 @@ namespace OpenSim.Region.Framework.Scenes
2079 2103
2080 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) 2104 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p)
2081 { 2105 {
2082 m_perfMonMS = Environment.TickCount; 2106 m_perfMonMS = EnvironmentTickCount();
2083 2107
2084 List<Vector3> CoarseLocations = new List<Vector3>(); 2108 List<Vector3> CoarseLocations = new List<Vector3>();
2085 List<UUID> AvatarUUIDs = new List<UUID>(); 2109 List<UUID> AvatarUUIDs = new List<UUID>();
@@ -2115,7 +2139,7 @@ namespace OpenSim.Region.Framework.Scenes
2115 2139
2116 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2140 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2117 2141
2118 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2142 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2119 } 2143 }
2120 2144
2121 public void CoarseLocationChange() 2145 public void CoarseLocationChange()
@@ -2152,7 +2176,7 @@ namespace OpenSim.Region.Framework.Scenes
2152 /// </summary> 2176 /// </summary>
2153 public void SendInitialFullUpdateToAllClients() 2177 public void SendInitialFullUpdateToAllClients()
2154 { 2178 {
2155 m_perfMonMS = Environment.TickCount; 2179 m_perfMonMS = EnvironmentTickCount();
2156 2180
2157 ScenePresence[] avatars = m_scene.GetScenePresences(); 2181 ScenePresence[] avatars = m_scene.GetScenePresences();
2158 2182
@@ -2178,14 +2202,14 @@ namespace OpenSim.Region.Framework.Scenes
2178 } 2202 }
2179 2203
2180 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2204 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2181 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2205 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2182 2206
2183 //Animator.SendAnimPack(); 2207 //Animator.SendAnimPack();
2184 } 2208 }
2185 2209
2186 public void SendFullUpdateToAllClients() 2210 public void SendFullUpdateToAllClients()
2187 { 2211 {
2188 m_perfMonMS = Environment.TickCount; 2212 m_perfMonMS = EnvironmentTickCount();
2189 2213
2190 // only send update from root agents to other clients; children are only "listening posts" 2214 // only send update from root agents to other clients; children are only "listening posts"
2191 List<ScenePresence> avatars = m_scene.GetAvatars(); 2215 List<ScenePresence> avatars = m_scene.GetAvatars();
@@ -2195,7 +2219,7 @@ namespace OpenSim.Region.Framework.Scenes
2195 2219
2196 } 2220 }
2197 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2221 m_scene.StatsReporter.AddAgentUpdates(avatars.Count);
2198 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2222 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2199 2223
2200 Animator.SendAnimPack(); 2224 Animator.SendAnimPack();
2201 } 2225 }
@@ -2237,7 +2261,7 @@ namespace OpenSim.Region.Framework.Scenes
2237 /// </summary> 2261 /// </summary>
2238 public void SendAppearanceToAllOtherAgents() 2262 public void SendAppearanceToAllOtherAgents()
2239 { 2263 {
2240 m_perfMonMS = Environment.TickCount; 2264 m_perfMonMS = EnvironmentTickCount();
2241 2265
2242 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2266 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2243 { 2267 {
@@ -2247,7 +2271,7 @@ namespace OpenSim.Region.Framework.Scenes
2247 } 2271 }
2248 }); 2272 });
2249 2273
2250 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2274 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS));
2251 } 2275 }
2252 2276
2253 /// <summary> 2277 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index ee288b3..f92f440 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Region.Framework.Scenes
82 private int m_fps = 0; 82 private int m_fps = 0;
83 // saved last reported value so there is something available for llGetRegionFPS 83 // saved last reported value so there is something available for llGetRegionFPS
84 private float lastReportedSimFPS = 0; 84 private float lastReportedSimFPS = 0;
85 private float[] lastReportedSimStats = new float[21];
85 private float m_pfps = 0; 86 private float m_pfps = 0;
86 private int m_agentUpdates = 0; 87 private int m_agentUpdates = 0;
87 88
@@ -192,6 +193,9 @@ namespace OpenSim.Region.Framework.Scenes
192 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 193 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
193 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 194 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
194 195
196 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
197 // values to X-per-second values.
198
195 for (int i = 0; i<21;i++) 199 for (int i = 0; i<21;i++)
196 { 200 {
197 sb[i] = new SimStatsPacket.StatBlock(); 201 sb[i] = new SimStatsPacket.StatBlock();
@@ -236,8 +240,8 @@ namespace OpenSim.Region.Framework.Scenes
236 sb[12].StatID = (uint)Stats.OtherMS; 240 sb[12].StatID = (uint)Stats.OtherMS;
237 sb[12].StatValue = m_otherMS / statsUpdateFactor; 241 sb[12].StatValue = m_otherMS / statsUpdateFactor;
238 242
239 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 243 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
240 sb[13].StatValue = (m_inPacketsPerSecond); 244 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor);
241 245
242 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 246 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
243 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 247 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
@@ -259,6 +263,11 @@ namespace OpenSim.Region.Framework.Scenes
259 263
260 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 264 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
261 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 265 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
266
267 for (int i = 0; i < 21; i++)
268 {
269 lastReportedSimStats[i] = sb[i].StatValue;
270 }
262 271
263 SimStats simStats 272 SimStats simStats
264 = new SimStats( 273 = new SimStats(
@@ -279,8 +288,8 @@ namespace OpenSim.Region.Framework.Scenes
279 m_fps = 0; 288 m_fps = 0;
280 m_pfps = 0; 289 m_pfps = 0;
281 m_agentUpdates = 0; 290 m_agentUpdates = 0;
282 m_inPacketsPerSecond = 0; 291 //m_inPacketsPerSecond = 0;
283 m_outPacketsPerSecond = 0; 292 //m_outPacketsPerSecond = 0;
284 m_unAckedBytes = 0; 293 m_unAckedBytes = 0;
285 m_scriptLinesPerSecond = 0; 294 m_scriptLinesPerSecond = 0;
286 295
@@ -367,12 +376,12 @@ namespace OpenSim.Region.Framework.Scenes
367 376
368 public void AddInPackets(int numPackets) 377 public void AddInPackets(int numPackets)
369 { 378 {
370 m_inPacketsPerSecond += numPackets; 379 m_inPacketsPerSecond = numPackets;
371 } 380 }
372 381
373 public void AddOutPackets(int numPackets) 382 public void AddOutPackets(int numPackets)
374 { 383 {
375 m_outPacketsPerSecond += numPackets; 384 m_outPacketsPerSecond = numPackets;
376 } 385 }
377 386
378 public void AddunAckedBytes(int numBytes) 387 public void AddunAckedBytes(int numBytes)
@@ -438,6 +447,11 @@ namespace OpenSim.Region.Framework.Scenes
438 { 447 {
439 return lastReportedSimFPS; 448 return lastReportedSimFPS;
440 } 449 }
450
451 public float[] getLastReportedSimStats()
452 {
453 return lastReportedSimStats;
454 }
441 455
442 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) 456 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes)
443 { 457 {