diff options
author | Melanie | 2012-04-17 01:54:54 +0100 |
---|---|---|
committer | Melanie | 2012-04-17 01:54:54 +0100 |
commit | 74aa8eee1255d457d0c865682a7c5466ae8d640e (patch) | |
tree | d7fed81841ad48e09836ee3582b7161921339f9e | |
parent | Merge branch 'master' of ssh://melanie@3dhosting.de/var/git/careminster into ... (diff) | |
parent | Add test TestGetChildPartPosition() (diff) | |
download | opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.zip opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.gz opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.bz2 opensim-SC-74aa8eee1255d457d0c865682a7c5466ae8d640e.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
11 files changed, 76 insertions, 139 deletions
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 142b783..1caf04a 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -346,7 +346,7 @@ namespace OpenSim.Framework | |||
346 | l_EstateManagers.Remove(avatarID); | 346 | l_EstateManagers.Remove(avatarID); |
347 | } | 347 | } |
348 | 348 | ||
349 | public bool IsEstateManager(UUID avatarID) | 349 | public bool IsEstateManagerOrOwner(UUID avatarID) |
350 | { | 350 | { |
351 | if (IsEstateOwner(avatarID)) | 351 | if (IsEstateOwner(avatarID)) |
352 | return true; | 352 | return true; |
@@ -411,7 +411,7 @@ namespace OpenSim.Framework | |||
411 | 411 | ||
412 | public bool HasAccess(UUID user) | 412 | public bool HasAccess(UUID user) |
413 | { | 413 | { |
414 | if (IsEstateManager(user)) | 414 | if (IsEstateManagerOrOwner(user)) |
415 | return true; | 415 | return true; |
416 | 416 | ||
417 | return l_EstateAccess.Contains(user); | 417 | return l_EstateAccess.Contains(user); |
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 34a3f15..6fde488 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -227,10 +227,10 @@ namespace OpenSim.Framework.Tests | |||
227 | es.AddEstateManager(UUID.Zero); | 227 | es.AddEstateManager(UUID.Zero); |
228 | 228 | ||
229 | es.AddEstateManager(bannedUserId); | 229 | es.AddEstateManager(bannedUserId); |
230 | Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); | 230 | Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserId should be EstateManager but isn't."); |
231 | 231 | ||
232 | es.RemoveEstateManager(bannedUserId); | 232 | es.RemoveEstateManager(bannedUserId); |
233 | Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); | 233 | Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserID is estateManager but shouldn't be"); |
234 | 234 | ||
235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); | 235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); |
236 | 236 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 366e02d..ddc2a07 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -998,7 +998,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
998 | { | 998 | { |
999 | RegionHandshakeArgs args = new RegionHandshakeArgs(); | 999 | RegionHandshakeArgs args = new RegionHandshakeArgs(); |
1000 | 1000 | ||
1001 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); | 1001 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId); |
1002 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) | 1002 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) |
1003 | args.isEstateManager = true; | 1003 | args.isEstateManager = true; |
1004 | 1004 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 9b2ddfd..16792b3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -487,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
487 | if (m_scene.Permissions.IsAdministrator(avatar)) | 487 | if (m_scene.Permissions.IsAdministrator(avatar)) |
488 | return false; | 488 | return false; |
489 | 489 | ||
490 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 490 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
491 | return false; | 491 | return false; |
492 | 492 | ||
493 | if (avatar == LandData.OwnerID) | 493 | if (avatar == LandData.OwnerID) |
@@ -517,7 +517,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
517 | if (m_scene.Permissions.IsAdministrator(avatar)) | 517 | if (m_scene.Permissions.IsAdministrator(avatar)) |
518 | return false; | 518 | return false; |
519 | 519 | ||
520 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 520 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
521 | return false; | 521 | return false; |
522 | 522 | ||
523 | if (avatar == LandData.OwnerID) | 523 | if (avatar == LandData.OwnerID) |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 82ccaf8..881b24a 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -503,7 +503,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
503 | { | 503 | { |
504 | if (user == UUID.Zero) return false; | 504 | if (user == UUID.Zero) return false; |
505 | 505 | ||
506 | return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); | 506 | return m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(user); |
507 | } | 507 | } |
508 | 508 | ||
509 | #endregion | 509 | #endregion |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a634c4..292dbdc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3946,7 +3946,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3946 | land.LandData.UserLocation != Vector3.Zero && | 3946 | land.LandData.UserLocation != Vector3.Zero && |
3947 | land.LandData.OwnerID != m_uuid && | 3947 | land.LandData.OwnerID != m_uuid && |
3948 | (!m_scene.Permissions.IsGod(m_uuid)) && | 3948 | (!m_scene.Permissions.IsGod(m_uuid)) && |
3949 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | 3949 | (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) |
3950 | { | 3950 | { |
3951 | float curr = Vector3.Distance(AbsolutePosition, pos); | 3951 | float curr = Vector3.Distance(AbsolutePosition, pos); |
3952 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | 3952 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) |
@@ -3966,7 +3966,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3966 | { | 3966 | { |
3967 | if (GodLevel < 200 && | 3967 | if (GodLevel < 200 && |
3968 | ((!m_scene.Permissions.IsGod(m_uuid) && | 3968 | ((!m_scene.Permissions.IsGod(m_uuid) && |
3969 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 3969 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
3970 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 3970 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
3971 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 3971 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
3972 | { | 3972 | { |
@@ -4040,7 +4040,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4040 | GodLevel < 200 && | 4040 | GodLevel < 200 && |
4041 | ((land.LandData.OwnerID != m_uuid && | 4041 | ((land.LandData.OwnerID != m_uuid && |
4042 | !m_scene.Permissions.IsGod(m_uuid) && | 4042 | !m_scene.Permissions.IsGod(m_uuid) && |
4043 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4043 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
4044 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4044 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
4045 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4045 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
4046 | { | 4046 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index 7a3b362..fffa3bd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -86,5 +86,33 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
86 | Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); | 86 | Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); |
87 | Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); | 87 | Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); |
88 | } | 88 | } |
89 | |||
90 | [Test] | ||
91 | public void TestGetChildPartPosition() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | |||
95 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
96 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
97 | |||
98 | SceneObjectGroup so | ||
99 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
100 | so.AbsolutePosition = rootPartPosition; | ||
101 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
102 | |||
103 | m_scene.AddNewSceneObject(so, false); | ||
104 | |||
105 | // Calculate child absolute position. | ||
106 | Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition); | ||
107 | |||
108 | SceneObjectPart childPart = so.Parts[1]; | ||
109 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition)); | ||
110 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
114 | |||
115 | // TODO: Write test for child part position after rotation. | ||
116 | } | ||
89 | } | 117 | } |
90 | } \ No newline at end of file | 118 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3a7eb32..e9ec314 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -9990,7 +9990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9990 | // child agents have a mass of 1.0 | 9990 | // child agents have a mass of 1.0 |
9991 | return 1; | 9991 | return 1; |
9992 | else | 9992 | else |
9993 | return avatar.GetMass(); | 9993 | return (double)avatar.GetMass(); |
9994 | } | 9994 | } |
9995 | catch (KeyNotFoundException) | 9995 | catch (KeyNotFoundException) |
9996 | { | 9996 | { |
@@ -12042,7 +12042,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12042 | bool isAccount = false; | 12042 | bool isAccount = false; |
12043 | bool isGroup = false; | 12043 | bool isGroup = false; |
12044 | 12044 | ||
12045 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) | 12045 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) |
12046 | return 0; | 12046 | return 0; |
12047 | 12047 | ||
12048 | UUID id = new UUID(); | 12048 | UUID id = new UUID(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 77a784d..df20126 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -449,7 +449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
449 | LSShoutError("LightShare functions are not enabled."); | 449 | LSShoutError("LightShare functions are not enabled."); |
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 452 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
453 | { | 453 | { |
454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
455 | return 0; | 455 | return 0; |
@@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
477 | LSShoutError("LightShare functions are not enabled."); | 477 | LSShoutError("LightShare functions are not enabled."); |
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 480 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
481 | { | 481 | { |
482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
483 | return; | 483 | return; |
@@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
500 | LSShoutError("LightShare functions are not enabled."); | 500 | LSShoutError("LightShare functions are not enabled."); |
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 503 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
504 | { | 504 | { |
505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
506 | return 0; | 506 | return 0; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index df49fd7..89e85a0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) | 378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) |
379 | { | 379 | { |
380 | //Only Estate Managers may use the function | 380 | //Only Estate Managers may use the function |
381 | if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 381 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
382 | { | 382 | { |
383 | return; | 383 | return; |
384 | } | 384 | } |
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index b9ba4bc..4248035 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics | |||
90 | 90 | ||
91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | 91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); |
92 | dbConn.Open(); | 92 | dbConn.Open(); |
93 | CheckAndUpdateDatabase(dbConn); | 93 | CreateTables(dbConn); |
94 | 94 | ||
95 | Prototype_distributor protodep = new Prototype_distributor(); | 95 | Prototype_distributor protodep = new Prototype_distributor(); |
96 | Updater_distributor updatedep = new Updater_distributor(); | 96 | Updater_distributor updatedep = new Updater_distributor(); |
@@ -131,7 +131,7 @@ namespace OpenSim.Region.UserStatistics | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public void ReceiveClassicSimStatsPacket(SimStats stats) | 134 | private void ReceiveClassicSimStatsPacket(SimStats stats) |
135 | { | 135 | { |
136 | if (!enabled) | 136 | if (!enabled) |
137 | { | 137 | { |
@@ -163,7 +163,7 @@ namespace OpenSim.Region.UserStatistics | |||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | public Hashtable HandleUnknownCAPSRequest(Hashtable request) | 166 | private Hashtable HandleUnknownCAPSRequest(Hashtable request) |
167 | { | 167 | { |
168 | //string regpath = request["uri"].ToString(); | 168 | //string regpath = request["uri"].ToString(); |
169 | int response_code = 200; | 169 | int response_code = 200; |
@@ -178,7 +178,7 @@ namespace OpenSim.Region.UserStatistics | |||
178 | return responsedata; | 178 | return responsedata; |
179 | } | 179 | } |
180 | 180 | ||
181 | public Hashtable HandleStatsRequest(Hashtable request) | 181 | private Hashtable HandleStatsRequest(Hashtable request) |
182 | { | 182 | { |
183 | lastHit = System.Environment.TickCount; | 183 | lastHit = System.Environment.TickCount; |
184 | Hashtable responsedata = new Hashtable(); | 184 | Hashtable responsedata = new Hashtable(); |
@@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics | |||
237 | 237 | ||
238 | return responsedata; | 238 | return responsedata; |
239 | } | 239 | } |
240 | |||
241 | public void CheckAndUpdateDatabase(SqliteConnection db) | ||
242 | { | ||
243 | lock (db) | ||
244 | { | ||
245 | // TODO: FIXME: implement stats migrations | ||
246 | const string SQL = @"SELECT * FROM migrations LIMIT 1"; | ||
247 | |||
248 | using (SqliteCommand cmd = new SqliteCommand(SQL, db)) | ||
249 | { | ||
250 | try | ||
251 | { | ||
252 | cmd.ExecuteNonQuery(); | ||
253 | } | ||
254 | catch (SqliteSyntaxException) | ||
255 | { | ||
256 | CreateTables(db); | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | 240 | ||
262 | public void CreateTables(SqliteConnection db) | 241 | private void CreateTables(SqliteConnection db) |
263 | { | 242 | { |
264 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) | 243 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) |
265 | { | 244 | { |
266 | createcmd.ExecuteNonQuery(); | 245 | createcmd.ExecuteNonQuery(); |
267 | |||
268 | createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; | ||
269 | createcmd.ExecuteNonQuery(); | ||
270 | } | 246 | } |
271 | } | 247 | } |
272 | 248 | ||
@@ -301,7 +277,7 @@ namespace OpenSim.Region.UserStatistics | |||
301 | get { return true; } | 277 | get { return true; } |
302 | } | 278 | } |
303 | 279 | ||
304 | public void OnRegisterCaps(UUID agentID, Caps caps) | 280 | private void OnRegisterCaps(UUID agentID, Caps caps) |
305 | { | 281 | { |
306 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 282 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
307 | 283 | ||
@@ -316,7 +292,7 @@ namespace OpenSim.Region.UserStatistics | |||
316 | })); | 292 | })); |
317 | } | 293 | } |
318 | 294 | ||
319 | public void OnDeRegisterCaps(UUID agentID, Caps caps) | 295 | private void OnDeRegisterCaps(UUID agentID, Caps caps) |
320 | { | 296 | { |
321 | } | 297 | } |
322 | 298 | ||
@@ -336,7 +312,7 @@ namespace OpenSim.Region.UserStatistics | |||
336 | } | 312 | } |
337 | } | 313 | } |
338 | 314 | ||
339 | public void OnMakeRootAgent(ScenePresence agent) | 315 | private void OnMakeRootAgent(ScenePresence agent) |
340 | { | 316 | { |
341 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); | 317 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); |
342 | 318 | ||
@@ -365,11 +341,11 @@ namespace OpenSim.Region.UserStatistics | |||
365 | } | 341 | } |
366 | } | 342 | } |
367 | 343 | ||
368 | public void OnMakeChildAgent(ScenePresence agent) | 344 | private void OnMakeChildAgent(ScenePresence agent) |
369 | { | 345 | { |
370 | } | 346 | } |
371 | 347 | ||
372 | public void OnClientClosed(UUID agentID, Scene scene) | 348 | private void OnClientClosed(UUID agentID, Scene scene) |
373 | { | 349 | { |
374 | lock (m_sessions) | 350 | lock (m_sessions) |
375 | { | 351 | { |
@@ -380,7 +356,7 @@ namespace OpenSim.Region.UserStatistics | |||
380 | } | 356 | } |
381 | } | 357 | } |
382 | 358 | ||
383 | public string readLogLines(int amount) | 359 | private string readLogLines(int amount) |
384 | { | 360 | { |
385 | Encoding encoding = Encoding.ASCII; | 361 | Encoding encoding = Encoding.ASCII; |
386 | int sizeOfChar = encoding.GetByteCount("\n"); | 362 | int sizeOfChar = encoding.GetByteCount("\n"); |
@@ -418,7 +394,7 @@ namespace OpenSim.Region.UserStatistics | |||
418 | return encoding.GetString(buffer); | 394 | return encoding.GetString(buffer); |
419 | } | 395 | } |
420 | 396 | ||
421 | public UUID GetRegionUUIDFromHandle(ulong regionhandle) | 397 | private UUID GetRegionUUIDFromHandle(ulong regionhandle) |
422 | { | 398 | { |
423 | lock (m_scenes) | 399 | lock (m_scenes) |
424 | { | 400 | { |
@@ -441,17 +417,17 @@ namespace OpenSim.Region.UserStatistics | |||
441 | /// <param name="agentID"></param> | 417 | /// <param name="agentID"></param> |
442 | /// <param name="caps"></param> | 418 | /// <param name="caps"></param> |
443 | /// <returns></returns> | 419 | /// <returns></returns> |
444 | public string ViewerStatsReport(string request, string path, string param, | 420 | private string ViewerStatsReport(string request, string path, string param, |
445 | UUID agentID, Caps caps) | 421 | UUID agentID, Caps caps) |
446 | { | 422 | { |
447 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); | 423 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); |
448 | 424 | ||
449 | UpdateUserStats(ParseViewerStats(request,agentID), dbConn); | 425 | UpdateUserStats(ParseViewerStats(request, agentID), dbConn); |
450 | 426 | ||
451 | return String.Empty; | 427 | return String.Empty; |
452 | } | 428 | } |
453 | 429 | ||
454 | public UserSessionID ParseViewerStats(string request, UUID agentID) | 430 | private UserSessionID ParseViewerStats(string request, UUID agentID) |
455 | { | 431 | { |
456 | UserSessionID uid = new UserSessionID(); | 432 | UserSessionID uid = new UserSessionID(); |
457 | UserSessionData usd; | 433 | UserSessionData usd; |
@@ -592,14 +568,14 @@ namespace OpenSim.Region.UserStatistics | |||
592 | return uid; | 568 | return uid; |
593 | } | 569 | } |
594 | 570 | ||
595 | public void UpdateUserStats(UserSessionID uid, SqliteConnection db) | 571 | private void UpdateUserStats(UserSessionID uid, SqliteConnection db) |
596 | { | 572 | { |
597 | if (uid.session_id == UUID.Zero) | 573 | if (uid.session_id == UUID.Zero) |
598 | return; | 574 | return; |
599 | 575 | ||
600 | lock (db) | 576 | lock (db) |
601 | { | 577 | { |
602 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db)) | 578 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_INSERT, db)) |
603 | { | 579 | { |
604 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); | 580 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); |
605 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); | 581 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); |
@@ -648,44 +624,26 @@ namespace OpenSim.Region.UserStatistics | |||
648 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); | 624 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); |
649 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); | 625 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); |
650 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); | 626 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); |
651 | |||
652 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); | 627 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); |
653 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); | 628 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); |
654 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); | 629 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); |
655 | |||
656 | updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); | ||
657 | updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); | ||
658 | updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); | ||
659 | 630 | ||
660 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); | 631 | // StringBuilder parameters = new StringBuilder(); |
661 | 632 | // SqliteParameterCollection spc = updatecmd.Parameters; | |
662 | int result = updatecmd.ExecuteNonQuery(); | 633 | // foreach (SqliteParameter sp in spc) |
663 | 634 | // parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value); | |
664 | if (result == 0) | 635 | // |
665 | { | 636 | // m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters); |
666 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id); | ||
667 | 637 | ||
668 | updatecmd.CommandText = SQL_STATS_TABLE_INSERT; | 638 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); |
669 | 639 | ||
670 | try | 640 | updatecmd.ExecuteNonQuery(); |
671 | { | ||
672 | updatecmd.ExecuteNonQuery(); | ||
673 | } | ||
674 | catch (Exception e) | ||
675 | { | ||
676 | m_log.WarnFormat( | ||
677 | "[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}", | ||
678 | uid.session_data.agent_id, e.Message, e.StackTrace); | ||
679 | } | ||
680 | } | ||
681 | } | 641 | } |
682 | } | 642 | } |
683 | } | 643 | } |
684 | 644 | ||
685 | #region SQL | 645 | #region SQL |
686 | private const string SQL_MIGRA_TABLE_CREATE = @"create table migrations(name varchar(100), version int)"; | 646 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data ( |
687 | |||
688 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data ( | ||
689 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, | 647 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, |
690 | agent_id VARCHAR(36) NOT NULL DEFAULT '', | 648 | agent_id VARCHAR(36) NOT NULL DEFAULT '', |
691 | region_id VARCHAR(36) NOT NULL DEFAULT '', | 649 | region_id VARCHAR(36) NOT NULL DEFAULT '', |
@@ -735,11 +693,11 @@ namespace OpenSim.Region.UserStatistics | |||
735 | f_send_packet INT NOT NULL DEFAULT '0' | 693 | f_send_packet INT NOT NULL DEFAULT '0' |
736 | );"; | 694 | );"; |
737 | 695 | ||
738 | private const string SQL_STATS_TABLE_INSERT = @"INSERT INTO stats_session_data ( | 696 | private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data ( |
739 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, | 697 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, |
740 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, | 698 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, |
741 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, | 699 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, |
742 | d_object_kb, d_texture_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_invalid, f_off_circuit, | 700 | d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit, |
743 | f_resent, f_send_packet | 701 | f_resent, f_send_packet |
744 | ) | 702 | ) |
745 | VALUES | 703 | VALUES |
@@ -747,62 +705,13 @@ VALUES | |||
747 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, | 705 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, |
748 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, | 706 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, |
749 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, | 707 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, |
750 | :d_object_kb, :d_texture_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_invalid, :f_off_circuit, | 708 | :d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit, |
751 | :f_resent, :f_send_packet | 709 | :f_resent, :f_send_packet |
752 | ) | 710 | ) |
753 | "; | 711 | "; |
754 | 712 | ||
755 | private const string SQL_STATS_TABLE_UPDATE = @" | 713 | #endregion |
756 | UPDATE stats_session_data | 714 | |
757 | set session_id=:session_id, | ||
758 | agent_id=:agent_id, | ||
759 | region_id=:region_id, | ||
760 | last_updated=:last_updated, | ||
761 | remote_ip=:remote_ip, | ||
762 | name_f=:name_f, | ||
763 | name_l=:name_l, | ||
764 | avg_agents_in_view=:avg_agents_in_view, | ||
765 | min_agents_in_view=:min_agents_in_view, | ||
766 | max_agents_in_view=:max_agents_in_view, | ||
767 | mode_agents_in_view=:mode_agents_in_view, | ||
768 | avg_fps=:avg_fps, | ||
769 | min_fps=:min_fps, | ||
770 | max_fps=:max_fps, | ||
771 | mode_fps=:mode_fps, | ||
772 | a_language=:a_language, | ||
773 | mem_use=:mem_use, | ||
774 | meters_traveled=:meters_traveled, | ||
775 | avg_ping=:avg_ping, | ||
776 | min_ping=:min_ping, | ||
777 | max_ping=:max_ping, | ||
778 | mode_ping=:mode_ping, | ||
779 | regions_visited=:regions_visited, | ||
780 | run_time=:run_time, | ||
781 | avg_sim_fps=:avg_sim_fps, | ||
782 | min_sim_fps=:min_sim_fps, | ||
783 | max_sim_fps=:max_sim_fps, | ||
784 | mode_sim_fps=:mode_sim_fps, | ||
785 | start_time=:start_time, | ||
786 | client_version=:client_version, | ||
787 | s_cpu=:s_cpu, | ||
788 | s_gpu=:s_gpu, | ||
789 | s_os=:s_os, | ||
790 | s_ram=:s_ram, | ||
791 | d_object_kb=:d_object_kb, | ||
792 | d_texture_kb=:d_texture_kb, | ||
793 | d_world_kb=:d_world_kb, | ||
794 | n_in_kb=:n_in_kb, | ||
795 | n_in_pk=:n_in_pk, | ||
796 | n_out_kb=:n_out_kb, | ||
797 | n_out_pk=:n_out_pk, | ||
798 | f_dropped=:f_dropped, | ||
799 | f_failed_resends=:f_failed_resends, | ||
800 | f_invalid=:f_invalid, | ||
801 | f_off_circuit=:f_off_circuit, | ||
802 | f_resent=:f_resent, | ||
803 | f_send_packet=:f_send_packet | ||
804 | WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; | ||
805 | #endregion | ||
806 | } | 715 | } |
807 | 716 | ||
808 | public static class UserSessionUtil | 717 | public static class UserSessionUtil |