From f213f55586b9af66955fdfccdd50237febaf98ca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 00:02:58 +0100 Subject: Fix bug in WebStatsModule where an exception would always be output on update if the user teleported to another region on that simulator. This was because update was looking for an existing stats record unique in session id, agent id and region id. But if the user teleports to another region then region id changes. WebStatsModule promptly doesn't find the existing record and tries to insert a new one, but only session id is the primary key and that's still the same, which makes things go bang. This makes the update search only on the unique session id. This is only an issue with simulators that have multiple regions where the webstats module is enabled. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index b9ba4bc..dbe9b3f 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -446,7 +446,7 @@ namespace OpenSim.Region.UserStatistics { // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); - UpdateUserStats(ParseViewerStats(request,agentID), dbConn); + UpdateUserStats(ParseViewerStats(request, agentID), dbConn); return String.Empty; } @@ -654,8 +654,6 @@ namespace OpenSim.Region.UserStatistics updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); - updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); - updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); @@ -667,11 +665,18 @@ namespace OpenSim.Region.UserStatistics updatecmd.CommandText = SQL_STATS_TABLE_INSERT; +// StringBuilder parameters = new StringBuilder(); +// SqliteParameterCollection spc = updatecmd.Parameters; +// foreach (SqliteParameter sp in spc) +// parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value); +// +// m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters); + try { updatecmd.ExecuteNonQuery(); } - catch (Exception e) + catch (SqliteExecutionException e) { m_log.WarnFormat( "[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}", @@ -801,7 +806,7 @@ set session_id=:session_id, f_off_circuit=:f_off_circuit, f_resent=:f_resent, f_send_packet=:f_send_packet -WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; +WHERE session_id=:session_key"; #endregion } -- cgit v1.1 From 1bb387333868e223c90519d18fa18b84bd1a4324 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 00:19:36 +0100 Subject: Simplify WebStatsModule by removing the uncompleted migrations section. Use "create table if not exists" instead. Client stats data is transitory data that it is not worth migrating. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 32 +++---------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index dbe9b3f..e593ecd 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); dbConn.Open(); - CheckAndUpdateDatabase(dbConn); + CreateTables(dbConn); Prototype_distributor protodep = new Prototype_distributor(); Updater_distributor updatedep = new Updater_distributor(); @@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics return responsedata; } - - public void CheckAndUpdateDatabase(SqliteConnection db) - { - lock (db) - { - // TODO: FIXME: implement stats migrations - const string SQL = @"SELECT * FROM migrations LIMIT 1"; - - using (SqliteCommand cmd = new SqliteCommand(SQL, db)) - { - try - { - cmd.ExecuteNonQuery(); - } - catch (SqliteSyntaxException) - { - CreateTables(db); - } - } - } - } public void CreateTables(SqliteConnection db) { using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) { createcmd.ExecuteNonQuery(); - - createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; - createcmd.ExecuteNonQuery(); } } @@ -688,9 +664,7 @@ namespace OpenSim.Region.UserStatistics } #region SQL - private const string SQL_MIGRA_TABLE_CREATE = @"create table migrations(name varchar(100), version int)"; - - private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data ( + private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data ( session_id VARCHAR(36) NOT NULL PRIMARY KEY, agent_id VARCHAR(36) NOT NULL DEFAULT '', region_id VARCHAR(36) NOT NULL DEFAULT '', @@ -807,8 +781,8 @@ set session_id=:session_id, f_resent=:f_resent, f_send_packet=:f_send_packet WHERE session_id=:session_key"; - #endregion } + #endregion public static class UserSessionUtil { -- cgit v1.1 From 572440cd23cdd5737979a2140b9d782b836fb952 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 00:33:23 +0100 Subject: correct bug where f_invalid was being inserted on a webstats update for an existing session rather than d_world_kb --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index e593ecd..cc041d1 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -718,7 +718,7 @@ namespace OpenSim.Region.UserStatistics 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, 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, 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, -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, +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, f_resent, f_send_packet ) VALUES @@ -726,7 +726,7 @@ VALUES :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, :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, :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, -: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, +: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, :f_resent, :f_send_packet ) "; -- cgit v1.1 From e6ec83125b9d77db833e18bbbdb396a31fb7b871 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 00:46:43 +0100 Subject: Use INSERT OR REPLACE INTO sql in WebStatsModule for session update rather than separate insert and update statements --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 84 +++---------------------- 1 file changed, 7 insertions(+), 77 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index cc041d1..a00955a 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -575,7 +575,7 @@ namespace OpenSim.Region.UserStatistics lock (db) { - using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db)) + using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_INSERT, db)) { updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); @@ -624,22 +624,9 @@ namespace OpenSim.Region.UserStatistics updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); - updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); - - updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); - -// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); - - int result = updatecmd.ExecuteNonQuery(); - - if (result == 0) - { -// m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id); - - updatecmd.CommandText = SQL_STATS_TABLE_INSERT; // StringBuilder parameters = new StringBuilder(); // SqliteParameterCollection spc = updatecmd.Parameters; @@ -648,17 +635,9 @@ namespace OpenSim.Region.UserStatistics // // m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters); - try - { - updatecmd.ExecuteNonQuery(); - } - catch (SqliteExecutionException e) - { - m_log.WarnFormat( - "[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}", - uid.session_data.agent_id, e.Message, e.StackTrace); - } - } +// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); + + updatecmd.ExecuteNonQuery(); } } } @@ -714,7 +693,7 @@ namespace OpenSim.Region.UserStatistics f_send_packet INT NOT NULL DEFAULT '0' );"; - private const string SQL_STATS_TABLE_INSERT = @"INSERT INTO stats_session_data ( + private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data ( 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, 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, 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, @@ -731,59 +710,10 @@ VALUES ) "; - private const string SQL_STATS_TABLE_UPDATE = @" -UPDATE stats_session_data -set session_id=:session_id, - agent_id=:agent_id, - region_id=:region_id, - last_updated=:last_updated, - remote_ip=:remote_ip, - name_f=:name_f, - name_l=:name_l, - avg_agents_in_view=:avg_agents_in_view, - min_agents_in_view=:min_agents_in_view, - max_agents_in_view=:max_agents_in_view, - mode_agents_in_view=:mode_agents_in_view, - avg_fps=:avg_fps, - min_fps=:min_fps, - max_fps=:max_fps, - mode_fps=:mode_fps, - a_language=:a_language, - mem_use=:mem_use, - meters_traveled=:meters_traveled, - avg_ping=:avg_ping, - min_ping=:min_ping, - max_ping=:max_ping, - mode_ping=:mode_ping, - regions_visited=:regions_visited, - run_time=:run_time, - avg_sim_fps=:avg_sim_fps, - min_sim_fps=:min_sim_fps, - max_sim_fps=:max_sim_fps, - mode_sim_fps=:mode_sim_fps, - start_time=:start_time, - client_version=:client_version, - s_cpu=:s_cpu, - s_gpu=:s_gpu, - s_os=:s_os, - s_ram=:s_ram, - d_object_kb=:d_object_kb, - d_texture_kb=:d_texture_kb, - d_world_kb=:d_world_kb, - n_in_kb=:n_in_kb, - n_in_pk=:n_in_pk, - n_out_kb=:n_out_kb, - n_out_pk=:n_out_pk, - f_dropped=:f_dropped, - f_failed_resends=:f_failed_resends, - f_invalid=:f_invalid, - f_off_circuit=:f_off_circuit, - f_resent=:f_resent, - f_send_packet=:f_send_packet -WHERE session_id=:session_key"; - } #endregion + } + public static class UserSessionUtil { public static UserSessionData newUserSessionData() -- cgit v1.1 From 5655239f440dce36cdf9288db70be567aef2d565 Mon Sep 17 00:00:00 2001 From: Talun Date: Mon, 16 Apr 2012 20:24:56 +0100 Subject: Null reference in llGetObjectMass on a seated avatar. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a19427d..5581727 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -9255,7 +9255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // child agents have a mass of 1.0 return 1; else - return (double)avatar.PhysicsActor.Mass; + return (double)avatar.GetMass(); } catch (KeyNotFoundException) { -- cgit v1.1 From 24a0cc5261f1fd1a1d8779c8fb5e7d7fba98ed68 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 01:25:41 +0100 Subject: refactor: Rename EstateSettings.IsEstateManager() to EstateSettings.IsEstateManagerOrOwner() to reflect what it actually does. This makes it consistent with other parts of OpenSimulator that are treating ESTATE_MANAGER and ESTATE_OWNER as different entities. As per opensim-dev mailing list. --- OpenSim/Framework/EstateSettings.cs | 4 ++-- OpenSim/Framework/Tests/MundaneFrameworkTests.cs | 4 ++-- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 +- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 4 ++-- OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++--- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | 6 +++--- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 98604f2..a92abbf 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -322,7 +322,7 @@ namespace OpenSim.Framework l_EstateManagers.Remove(avatarID); } - public bool IsEstateManager(UUID avatarID) + public bool IsEstateManagerOrOwner(UUID avatarID) { if (IsEstateOwner(avatarID)) return true; @@ -368,7 +368,7 @@ namespace OpenSim.Framework public bool HasAccess(UUID user) { - if (IsEstateManager(user)) + if (IsEstateManagerOrOwner(user)) return true; return l_EstateAccess.Contains(user); diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 76de6be..672847d 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs @@ -227,10 +227,10 @@ namespace OpenSim.Framework.Tests es.AddEstateManager(UUID.Zero); es.AddEstateManager(bannedUserId); - Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); + Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserId should be EstateManager but isn't."); es.RemoveEstateManager(bannedUserId); - Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); + Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserID is estateManager but shouldn't be"); Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 124f01c..58bbd24 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -967,7 +967,7 @@ namespace OpenSim.Region.CoreModules.World.Estate { RegionHandshakeArgs args = new RegionHandshakeArgs(); - args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); + args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId); if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) args.isEstateManager = true; diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 7f44613..0536f6e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -469,7 +469,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.IsAdministrator(avatar)) return false; - if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) + if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) return false; if (avatar == LandData.OwnerID) @@ -499,7 +499,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.IsAdministrator(avatar)) return false; - if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) + if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) return false; if (avatar == LandData.OwnerID) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 64759a7..2032905 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 { if (user == UUID.Zero) return false; - return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); + return m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(user); } #endregion diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 641d742..b5f789b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3832,7 +3832,7 @@ namespace OpenSim.Region.Framework.Scenes land.LandData.UserLocation != Vector3.Zero && land.LandData.OwnerID != m_uuid && (!m_scene.Permissions.IsGod(m_uuid)) && - (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) + (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) { float curr = Vector3.Distance(AbsolutePosition, pos); if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) @@ -3852,7 +3852,7 @@ namespace OpenSim.Region.Framework.Scenes { if (GodLevel < 200 && ((!m_scene.Permissions.IsGod(m_uuid) && - !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || + !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) { @@ -3920,7 +3920,7 @@ namespace OpenSim.Region.Framework.Scenes GodLevel < 200 && ((land.LandData.OwnerID != m_uuid && !m_scene.Permissions.IsGod(m_uuid) && - !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || + !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5581727..36c9d5e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10887,7 +10887,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool isAccount = false; bool isGroup = false; - if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) + if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) return 0; 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 LSShoutError("LightShare functions are not enabled."); return 0; } - if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) + if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) { LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); return 0; @@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSShoutError("LightShare functions are not enabled."); return; } - if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) + if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) { LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); return; @@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSShoutError("LightShare functions are not enabled."); return 0; } - if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) + if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) { LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 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 2680ad0..fe94b79 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -369,7 +369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) { //Only Estate Managers may use the function - if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) + if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) { return; } -- cgit v1.1 From 7e1ab216e3c8b7ade3f007d352451c9d9d742b5c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 01:33:55 +0100 Subject: Move some public methods on WebStatsModule to private to reduce some static analysis complexity. There's no obvious reason for these methods to be public. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index a00955a..4248035 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -131,7 +131,7 @@ namespace OpenSim.Region.UserStatistics } } - public void ReceiveClassicSimStatsPacket(SimStats stats) + private void ReceiveClassicSimStatsPacket(SimStats stats) { if (!enabled) { @@ -163,7 +163,7 @@ namespace OpenSim.Region.UserStatistics } } - public Hashtable HandleUnknownCAPSRequest(Hashtable request) + private Hashtable HandleUnknownCAPSRequest(Hashtable request) { //string regpath = request["uri"].ToString(); int response_code = 200; @@ -178,7 +178,7 @@ namespace OpenSim.Region.UserStatistics return responsedata; } - public Hashtable HandleStatsRequest(Hashtable request) + private Hashtable HandleStatsRequest(Hashtable request) { lastHit = System.Environment.TickCount; Hashtable responsedata = new Hashtable(); @@ -238,7 +238,7 @@ namespace OpenSim.Region.UserStatistics return responsedata; } - public void CreateTables(SqliteConnection db) + private void CreateTables(SqliteConnection db) { using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) { @@ -277,7 +277,7 @@ namespace OpenSim.Region.UserStatistics get { return true; } } - public void OnRegisterCaps(UUID agentID, Caps caps) + private void OnRegisterCaps(UUID agentID, Caps caps) { // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); @@ -292,7 +292,7 @@ namespace OpenSim.Region.UserStatistics })); } - public void OnDeRegisterCaps(UUID agentID, Caps caps) + private void OnDeRegisterCaps(UUID agentID, Caps caps) { } @@ -312,7 +312,7 @@ namespace OpenSim.Region.UserStatistics } } - public void OnMakeRootAgent(ScenePresence agent) + private void OnMakeRootAgent(ScenePresence agent) { UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); @@ -341,11 +341,11 @@ namespace OpenSim.Region.UserStatistics } } - public void OnMakeChildAgent(ScenePresence agent) + private void OnMakeChildAgent(ScenePresence agent) { } - public void OnClientClosed(UUID agentID, Scene scene) + private void OnClientClosed(UUID agentID, Scene scene) { lock (m_sessions) { @@ -356,7 +356,7 @@ namespace OpenSim.Region.UserStatistics } } - public string readLogLines(int amount) + private string readLogLines(int amount) { Encoding encoding = Encoding.ASCII; int sizeOfChar = encoding.GetByteCount("\n"); @@ -394,7 +394,7 @@ namespace OpenSim.Region.UserStatistics return encoding.GetString(buffer); } - public UUID GetRegionUUIDFromHandle(ulong regionhandle) + private UUID GetRegionUUIDFromHandle(ulong regionhandle) { lock (m_scenes) { @@ -417,7 +417,7 @@ namespace OpenSim.Region.UserStatistics /// /// /// - public string ViewerStatsReport(string request, string path, string param, + private string ViewerStatsReport(string request, string path, string param, UUID agentID, Caps caps) { // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); @@ -427,7 +427,7 @@ namespace OpenSim.Region.UserStatistics return String.Empty; } - public UserSessionID ParseViewerStats(string request, UUID agentID) + private UserSessionID ParseViewerStats(string request, UUID agentID) { UserSessionID uid = new UserSessionID(); UserSessionData usd; @@ -568,7 +568,7 @@ namespace OpenSim.Region.UserStatistics return uid; } - public void UpdateUserStats(UserSessionID uid, SqliteConnection db) + private void UpdateUserStats(UserSessionID uid, SqliteConnection db) { if (uid.session_id == UUID.Zero) return; -- cgit v1.1 From 2f2181683c9b3963da5e1cfd7fa1c6491d8a2ac0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Apr 2012 01:51:13 +0100 Subject: Add test TestGetChildPartPosition() --- .../Scenes/Tests/SceneObjectSpatialTests.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); } + + [Test] + public void TestGetChildPartPosition() + { + TestHelpers.InMethod(); + + Vector3 rootPartPosition = new Vector3(10, 20, 30); + Vector3 childOffsetPosition = new Vector3(2, 3, 4); + + SceneObjectGroup so + = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); + so.AbsolutePosition = rootPartPosition; + so.Parts[1].OffsetPosition = childOffsetPosition; + + m_scene.AddNewSceneObject(so, false); + + // Calculate child absolute position. + Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition); + + SceneObjectPart childPart = so.Parts[1]; + Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition)); + Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); + Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); + Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); + Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); + + // TODO: Write test for child part position after rotation. + } } } \ No newline at end of file -- cgit v1.1