Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.csavinationmerge
commit
74aa8eee12
|
@ -346,7 +346,7 @@ namespace OpenSim.Framework
|
||||||
l_EstateManagers.Remove(avatarID);
|
l_EstateManagers.Remove(avatarID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEstateManager(UUID avatarID)
|
public bool IsEstateManagerOrOwner(UUID avatarID)
|
||||||
{
|
{
|
||||||
if (IsEstateOwner(avatarID))
|
if (IsEstateOwner(avatarID))
|
||||||
return true;
|
return true;
|
||||||
|
@ -411,7 +411,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public bool HasAccess(UUID user)
|
public bool HasAccess(UUID user)
|
||||||
{
|
{
|
||||||
if (IsEstateManager(user))
|
if (IsEstateManagerOrOwner(user))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return l_EstateAccess.Contains(user);
|
return l_EstateAccess.Contains(user);
|
||||||
|
|
|
@ -227,10 +227,10 @@ namespace OpenSim.Framework.Tests
|
||||||
es.AddEstateManager(UUID.Zero);
|
es.AddEstateManager(UUID.Zero);
|
||||||
|
|
||||||
es.AddEstateManager(bannedUserId);
|
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);
|
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");
|
Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
|
||||||
|
|
||||||
|
|
|
@ -998,7 +998,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
{
|
{
|
||||||
RegionHandshakeArgs args = new RegionHandshakeArgs();
|
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)
|
if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
|
||||||
args.isEstateManager = true;
|
args.isEstateManager = true;
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
if (m_scene.Permissions.IsAdministrator(avatar))
|
if (m_scene.Permissions.IsAdministrator(avatar))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
|
if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (avatar == LandData.OwnerID)
|
if (avatar == LandData.OwnerID)
|
||||||
|
@ -517,7 +517,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
if (m_scene.Permissions.IsAdministrator(avatar))
|
if (m_scene.Permissions.IsAdministrator(avatar))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
|
if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (avatar == LandData.OwnerID)
|
if (avatar == LandData.OwnerID)
|
||||||
|
|
|
@ -503,7 +503,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||||
{
|
{
|
||||||
if (user == UUID.Zero) return false;
|
if (user == UUID.Zero) return false;
|
||||||
|
|
||||||
return m_scene.RegionInfo.EstateSettings.IsEstateManager(user);
|
return m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -3946,7 +3946,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
land.LandData.UserLocation != Vector3.Zero &&
|
land.LandData.UserLocation != Vector3.Zero &&
|
||||||
land.LandData.OwnerID != m_uuid &&
|
land.LandData.OwnerID != m_uuid &&
|
||||||
(!m_scene.Permissions.IsGod(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);
|
float curr = Vector3.Distance(AbsolutePosition, pos);
|
||||||
if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
|
if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
|
||||||
|
@ -3966,7 +3966,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (GodLevel < 200 &&
|
if (GodLevel < 200 &&
|
||||||
((!m_scene.Permissions.IsGod(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 & TeleportFlags.ViaLocation) != 0 ||
|
||||||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
|
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
|
||||||
{
|
{
|
||||||
|
@ -4040,7 +4040,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
GodLevel < 200 &&
|
GodLevel < 200 &&
|
||||||
((land.LandData.OwnerID != m_uuid &&
|
((land.LandData.OwnerID != m_uuid &&
|
||||||
!m_scene.Permissions.IsGod(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 & TeleportFlags.ViaLocation) != 0 ||
|
||||||
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
|
(m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,5 +86,33 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition));
|
Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition));
|
||||||
Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero));
|
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.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9990,7 +9990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
// child agents have a mass of 1.0
|
// child agents have a mass of 1.0
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return avatar.GetMass();
|
return (double)avatar.GetMass();
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -12042,7 +12042,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
bool isAccount = false;
|
bool isAccount = false;
|
||||||
bool isGroup = 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;
|
return 0;
|
||||||
|
|
||||||
UUID id = new UUID();
|
UUID id = new UUID();
|
||||||
|
|
|
@ -449,7 +449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
LSShoutError("LightShare functions are not enabled.");
|
LSShoutError("LightShare functions are not enabled.");
|
||||||
return 0;
|
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.");
|
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
LSShoutError("LightShare functions are not enabled.");
|
LSShoutError("LightShare functions are not enabled.");
|
||||||
return;
|
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.");
|
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||||
return;
|
return;
|
||||||
|
@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
LSShoutError("LightShare functions are not enabled.");
|
LSShoutError("LightShare functions are not enabled.");
|
||||||
return 0;
|
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.");
|
LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
|
if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
|
||||||
{
|
{
|
||||||
//Only Estate Managers may use the function
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3");
|
dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3");
|
||||||
dbConn.Open();
|
dbConn.Open();
|
||||||
CheckAndUpdateDatabase(dbConn);
|
CreateTables(dbConn);
|
||||||
|
|
||||||
Prototype_distributor protodep = new Prototype_distributor();
|
Prototype_distributor protodep = new Prototype_distributor();
|
||||||
Updater_distributor updatedep = new Updater_distributor();
|
Updater_distributor updatedep = new Updater_distributor();
|
||||||
|
@ -131,7 +131,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReceiveClassicSimStatsPacket(SimStats stats)
|
private void ReceiveClassicSimStatsPacket(SimStats stats)
|
||||||
{
|
{
|
||||||
if (!enabled)
|
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();
|
//string regpath = request["uri"].ToString();
|
||||||
int response_code = 200;
|
int response_code = 200;
|
||||||
|
@ -178,7 +178,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable HandleStatsRequest(Hashtable request)
|
private Hashtable HandleStatsRequest(Hashtable request)
|
||||||
{
|
{
|
||||||
lastHit = System.Environment.TickCount;
|
lastHit = System.Environment.TickCount;
|
||||||
Hashtable responsedata = new Hashtable();
|
Hashtable responsedata = new Hashtable();
|
||||||
|
@ -238,35 +238,11 @@ namespace OpenSim.Region.UserStatistics
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckAndUpdateDatabase(SqliteConnection db)
|
private void CreateTables(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))
|
using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db))
|
||||||
{
|
{
|
||||||
createcmd.ExecuteNonQuery();
|
createcmd.ExecuteNonQuery();
|
||||||
|
|
||||||
createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
|
|
||||||
createcmd.ExecuteNonQuery();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +277,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
get { return true; }
|
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);
|
// m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
|
||||||
|
|
||||||
|
@ -316,7 +292,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDeRegisterCaps(UUID agentID, Caps caps)
|
private void OnDeRegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +312,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMakeRootAgent(ScenePresence agent)
|
private void OnMakeRootAgent(ScenePresence agent)
|
||||||
{
|
{
|
||||||
UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle);
|
UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle);
|
||||||
|
|
||||||
|
@ -365,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)
|
lock (m_sessions)
|
||||||
{
|
{
|
||||||
|
@ -380,7 +356,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string readLogLines(int amount)
|
private string readLogLines(int amount)
|
||||||
{
|
{
|
||||||
Encoding encoding = Encoding.ASCII;
|
Encoding encoding = Encoding.ASCII;
|
||||||
int sizeOfChar = encoding.GetByteCount("\n");
|
int sizeOfChar = encoding.GetByteCount("\n");
|
||||||
|
@ -418,7 +394,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
return encoding.GetString(buffer);
|
return encoding.GetString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID GetRegionUUIDFromHandle(ulong regionhandle)
|
private UUID GetRegionUUIDFromHandle(ulong regionhandle)
|
||||||
{
|
{
|
||||||
lock (m_scenes)
|
lock (m_scenes)
|
||||||
{
|
{
|
||||||
|
@ -441,17 +417,17 @@ namespace OpenSim.Region.UserStatistics
|
||||||
/// <param name="agentID"></param>
|
/// <param name="agentID"></param>
|
||||||
/// <param name="caps"></param>
|
/// <param name="caps"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string ViewerStatsReport(string request, string path, string param,
|
private string ViewerStatsReport(string request, string path, string param,
|
||||||
UUID agentID, Caps caps)
|
UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID);
|
// 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;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserSessionID ParseViewerStats(string request, UUID agentID)
|
private UserSessionID ParseViewerStats(string request, UUID agentID)
|
||||||
{
|
{
|
||||||
UserSessionID uid = new UserSessionID();
|
UserSessionID uid = new UserSessionID();
|
||||||
UserSessionData usd;
|
UserSessionData usd;
|
||||||
|
@ -592,14 +568,14 @@ namespace OpenSim.Region.UserStatistics
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUserStats(UserSessionID uid, SqliteConnection db)
|
private void UpdateUserStats(UserSessionID uid, SqliteConnection db)
|
||||||
{
|
{
|
||||||
if (uid.session_id == UUID.Zero)
|
if (uid.session_id == UUID.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (db)
|
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(":session_id", uid.session_data.session_id.ToString()));
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
|
updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
|
||||||
|
@ -648,44 +624,26 @@ namespace OpenSim.Region.UserStatistics
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped));
|
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_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_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_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_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(":f_send_packet", uid.session_data.f_send_packet));
|
||||||
|
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString()));
|
// StringBuilder parameters = new StringBuilder();
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString()));
|
// SqliteParameterCollection spc = updatecmd.Parameters;
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString()));
|
// foreach (SqliteParameter sp in spc)
|
||||||
|
// parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value);
|
||||||
|
//
|
||||||
|
// m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters);
|
||||||
|
|
||||||
// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id);
|
// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id);
|
||||||
|
|
||||||
int result = updatecmd.ExecuteNonQuery();
|
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;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
updatecmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region SQL
|
#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 IF NOT EXISTS stats_session_data (
|
||||||
|
|
||||||
private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data (
|
|
||||||
session_id VARCHAR(36) NOT NULL PRIMARY KEY,
|
session_id VARCHAR(36) NOT NULL PRIMARY KEY,
|
||||||
agent_id VARCHAR(36) NOT NULL DEFAULT '',
|
agent_id VARCHAR(36) NOT NULL DEFAULT '',
|
||||||
region_id VARCHAR(36) NOT NULL DEFAULT '',
|
region_id VARCHAR(36) NOT NULL DEFAULT '',
|
||||||
|
@ -735,11 +693,11 @@ namespace OpenSim.Region.UserStatistics
|
||||||
f_send_packet INT NOT NULL DEFAULT '0'
|
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,
|
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,
|
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,
|
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
|
f_resent, f_send_packet
|
||||||
)
|
)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -747,62 +705,13 @@ 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,
|
: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,
|
: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,
|
: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
|
:f_resent, :f_send_packet
|
||||||
)
|
)
|
||||||
";
|
";
|
||||||
|
|
||||||
private const string SQL_STATS_TABLE_UPDATE = @"
|
#endregion
|
||||||
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 AND agent_id=:agent_key AND region_id=:region_key";
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UserSessionUtil
|
public static class UserSessionUtil
|
||||||
|
|
Loading…
Reference in New Issue