Compare commits

...

4 Commits

Author SHA1 Message Date
UbitUmarov
5b2ca76fcb avoid some future problem, thx Deiji 2026-04-30 05:53:46 +01:00
UbitUmarov
c6733b8c80 cosmetics on a blobfish 2026-04-27 19:40:51 +01:00
UbitUmarov
d068a68583 cosmetics 2026-04-27 14:06:55 +01:00
UbitUmarov
b713c3047e cosmetics 2026-04-26 21:58:41 +01:00
10 changed files with 204 additions and 267 deletions

View File

@@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse; using OpenMetaverse;
@@ -96,14 +97,15 @@ namespace OpenSim.Groups
public class GroupsDataUtils public class GroupsDataUtils
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Sanitize(string s) public static string Sanitize(string s)
{ {
return s == null ? string.Empty : s; return s ?? string.Empty;
} }
public static Dictionary<string, object> GroupRecord(ExtendedGroupRecord grec) public static Dictionary<string, object> GroupRecord(ExtendedGroupRecord grec)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); Dictionary<string, object> dict = [];
if (grec == null) if (grec == null)
return dict; return dict;
@@ -132,65 +134,66 @@ namespace OpenSim.Groups
return null; return null;
ExtendedGroupRecord grec = new ExtendedGroupRecord(); ExtendedGroupRecord grec = new ExtendedGroupRecord();
if (dict.ContainsKey("AllowPublish") && dict["AllowPublish"] != null) object otmp;
grec.AllowPublish = bool.Parse(dict["AllowPublish"].ToString()); if (dict.TryGetValue("AllowPublish", out otmp) && otmp != null)
grec.AllowPublish = bool.Parse(otmp.ToString());
if (dict.ContainsKey("Charter") && dict["Charter"] != null) if (dict.TryGetValue("Charter", out otmp) && otmp != null)
grec.Charter = dict["Charter"].ToString(); grec.Charter = otmp.ToString();
else else
grec.Charter = string.Empty; grec.Charter = string.Empty;
if (dict.ContainsKey("FounderID") && dict["FounderID"] != null) if (dict.TryGetValue("FounderID", out otmp) && otmp != null)
grec.FounderID = UUID.Parse(dict["FounderID"].ToString()); grec.FounderID = UUID.Parse(dict["FounderID"].ToString());
if (dict.ContainsKey("FounderUUI") && dict["FounderUUI"] != null) if (dict.TryGetValue("FounderUUI", out otmp) && otmp != null)
grec.FounderUUI = dict["FounderUUI"].ToString(); grec.FounderUUI = otmp.ToString();
else else
grec.FounderUUI = string.Empty; grec.FounderUUI = string.Empty;
if (dict.ContainsKey("GroupID") && dict["GroupID"] != null) if (dict.TryGetValue("GroupID", out otmp) && otmp != null)
grec.GroupID = UUID.Parse(dict["GroupID"].ToString()); grec.GroupID = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("GroupName") && dict["GroupName"] != null) if (dict.TryGetValue("GroupName", out otmp) && otmp != null)
grec.GroupName = dict["GroupName"].ToString(); grec.GroupName = otmp.ToString();
else else
grec.GroupName = string.Empty; grec.GroupName = string.Empty;
if (dict.ContainsKey("InsigniaID") && dict["InsigniaID"] != null) if (dict.TryGetValue("InsigniaID", out otmp) && otmp != null)
grec.GroupPicture = UUID.Parse(dict["InsigniaID"].ToString()); grec.GroupPicture = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("MaturePublish") && dict["MaturePublish"] != null) if (dict.TryGetValue("MaturePublish", out otmp) && otmp != null)
grec.MaturePublish = bool.Parse(dict["MaturePublish"].ToString()); grec.MaturePublish = bool.Parse(otmp.ToString());
if (dict.ContainsKey("MembershipFee") && dict["MembershipFee"] != null) if (dict.TryGetValue("MembershipFee", out otmp) && otmp != null)
grec.MembershipFee = Int32.Parse(dict["MembershipFee"].ToString()); grec.MembershipFee = int.Parse(otmp.ToString());
if (dict.ContainsKey("OpenEnrollment") && dict["OpenEnrollment"] != null) if (dict.TryGetValue("OpenEnrollment", out otmp) && otmp != null)
grec.OpenEnrollment = bool.Parse(dict["OpenEnrollment"].ToString()); grec.OpenEnrollment = bool.Parse(otmp.ToString());
if (dict.ContainsKey("OwnerRoleID") && dict["OwnerRoleID"] != null) if (dict.TryGetValue("OwnerRoleID", out otmp) && otmp != null)
grec.OwnerRoleID = UUID.Parse(dict["OwnerRoleID"].ToString()); grec.OwnerRoleID = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("ServiceLocation") && dict["ServiceLocation"] != null) if (dict.TryGetValue("ServiceLocation", out otmp) && otmp != null)
grec.ServiceLocation = dict["ServiceLocation"].ToString(); grec.ServiceLocation = otmp.ToString();
else else
grec.ServiceLocation = string.Empty; grec.ServiceLocation = string.Empty;
if (dict.ContainsKey("ShownInList") && dict["ShownInList"] != null) if (dict.TryGetValue("ShownInList", out otmp) && otmp != null)
grec.ShowInList = bool.Parse(dict["ShownInList"].ToString()); grec.ShowInList = bool.Parse(otmp.ToString());
if (dict.ContainsKey("MemberCount") && dict["MemberCount"] != null) if (dict.TryGetValue("MemberCount", out otmp) && otmp != null)
grec.MemberCount = Int32.Parse(dict["MemberCount"].ToString()); grec.MemberCount = int.Parse(otmp.ToString());
if (dict.ContainsKey("RoleCount") && dict["RoleCount"] != null) if (dict.TryGetValue("RoleCount", out otmp) && otmp != null)
grec.RoleCount = Int32.Parse(dict["RoleCount"].ToString()); grec.RoleCount = int.Parse(otmp.ToString());
return grec; return grec;
} }
public static Dictionary<string, object> GroupMembershipData(ExtendedGroupMembershipData membership) public static Dictionary<string, object> GroupMembershipData(ExtendedGroupMembershipData membership)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); Dictionary<string, object> dict = [];
if (membership == null) if (membership == null)
return dict; return dict;
@@ -222,68 +225,68 @@ namespace OpenSim.Groups
return null; return null;
ExtendedGroupMembershipData membership = new ExtendedGroupMembershipData(); ExtendedGroupMembershipData membership = new ExtendedGroupMembershipData();
object otmp;
if (dict.TryGetValue("AcceptNotices", out otmp) && otmp != null)
membership.AcceptNotices = bool.Parse(otmp.ToString());
if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null) if (dict.TryGetValue("AccessToken", out otmp) && otmp != null)
membership.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString()); membership.AccessToken = otmp.ToString();
if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null)
membership.AccessToken = dict["AccessToken"].ToString();
else else
membership.AccessToken = string.Empty; membership.AccessToken = string.Empty;
if (dict.ContainsKey("Active") && dict["Active"] != null) if (dict.TryGetValue("Active", out otmp) && otmp != null)
membership.Active = bool.Parse(dict["Active"].ToString()); membership.Active = bool.Parse(otmp.ToString());
if (dict.ContainsKey("ActiveRole") && dict["ActiveRole"] != null) if (dict.TryGetValue("ActiveRole", out otmp) && otmp != null)
membership.ActiveRole = UUID.Parse(dict["ActiveRole"].ToString()); membership.ActiveRole = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("AllowPublish") && dict["AllowPublish"] != null) if (dict.TryGetValue("AllowPublish", out otmp) && otmp != null)
membership.AllowPublish = bool.Parse(dict["AllowPublish"].ToString()); membership.AllowPublish = bool.Parse(otmp.ToString());
if (dict.ContainsKey("Charter") && dict["Charter"] != null) if (dict.TryGetValue("Charter", out otmp) && otmp != null)
membership.Charter = dict["Charter"].ToString(); membership.Charter = otmp.ToString();
else else
membership.Charter = string.Empty; membership.Charter = string.Empty;
if (dict.ContainsKey("Contribution") && dict["Contribution"] != null) if (dict.TryGetValue("Contribution", out otmp) && otmp != null)
membership.Contribution = Int32.Parse(dict["Contribution"].ToString()); membership.Contribution = int.Parse(otmp.ToString());
if (dict.ContainsKey("FounderID") && dict["FounderID"] != null) if (dict.TryGetValue("FounderID", out otmp) && otmp != null)
membership.FounderID = UUID.Parse(dict["FounderID"].ToString()); membership.FounderID = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("GroupID") && dict["GroupID"] != null) if (dict.TryGetValue("GroupID", out otmp) && otmp != null)
membership.GroupID = UUID.Parse(dict["GroupID"].ToString()); membership.GroupID = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("GroupName") && dict["GroupName"] != null) if (dict.TryGetValue("GroupName", out otmp) && otmp != null)
membership.GroupName = dict["GroupName"].ToString(); membership.GroupName = otmp.ToString();
else else
membership.GroupName = string.Empty; membership.GroupName = string.Empty;
if (dict.ContainsKey("GroupPicture") && dict["GroupPicture"] != null) if (dict.TryGetValue("GroupPicture", out otmp) && otmp != null)
membership.GroupPicture = UUID.Parse(dict["GroupPicture"].ToString()); membership.GroupPicture = UUID.Parse(otmp.ToString());
if (dict.ContainsKey("GroupPowers") && dict["GroupPowers"] != null) if (dict.TryGetValue("GroupPowers", out otmp) && otmp != null)
membership.GroupPowers = UInt64.Parse(dict["GroupPowers"].ToString()); membership.GroupPowers = ulong.Parse(otmp.ToString());
if (dict.ContainsKey("GroupTitle") && dict["GroupTitle"] != null) if (dict.TryGetValue("GroupTitle", out otmp) && otmp != null)
membership.GroupTitle = dict["GroupTitle"].ToString(); membership.GroupTitle = otmp.ToString();
else else
membership.GroupTitle = string.Empty; membership.GroupTitle = string.Empty;
if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null) if (dict.TryGetValue("ListInProfile", out otmp) && otmp != null)
membership.ListInProfile = bool.Parse(dict["ListInProfile"].ToString()); membership.ListInProfile = bool.Parse(otmp.ToString());
if (dict.ContainsKey("MaturePublish") && dict["MaturePublish"] != null) if (dict.TryGetValue("MaturePublish", out otmp) && otmp != null)
membership.MaturePublish = bool.Parse(dict["MaturePublish"].ToString()); membership.MaturePublish = bool.Parse(otmp.ToString());
if (dict.ContainsKey("MembershipFee") && dict["MembershipFee"] != null) if (dict.TryGetValue("MembershipFee", out otmp) && otmp != null)
membership.MembershipFee = Int32.Parse(dict["MembershipFee"].ToString()); membership.MembershipFee = int.Parse(otmp.ToString());
if (dict.ContainsKey("OpenEnrollment") && dict["OpenEnrollment"] != null) if (dict.TryGetValue("OpenEnrollment", out otmp) && otmp != null)
membership.OpenEnrollment = bool.Parse(dict["OpenEnrollment"].ToString()); membership.OpenEnrollment = bool.Parse(otmp.ToString());
if (dict.ContainsKey("ShowInList") && dict["ShowInList"] != null) if (dict.TryGetValue("ShowInList", out otmp) && otmp != null)
membership.ShowInList = bool.Parse(dict["ShowInList"].ToString()); membership.ShowInList = bool.Parse(otmp.ToString());
return membership; return membership;
} }
@@ -312,38 +315,39 @@ namespace OpenSim.Groups
if (dict == null) if (dict == null)
return member; return member;
if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null) object value;
member.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString()); if (dict.TryGetValue("AcceptNotices", out value) && value != null)
member.AcceptNotices = bool.Parse(value.ToString());
if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null) if (dict.TryGetValue("AccessToken", out value) && value != null)
member.AccessToken = Sanitize(dict["AccessToken"].ToString()); member.AccessToken = value.ToString();
else else
member.AccessToken = string.Empty; member.AccessToken = string.Empty;
if (dict.ContainsKey("AgentID") && dict["AgentID"] != null) if (dict.TryGetValue("AgentID", out value) && value != null)
member.AgentID = Sanitize(dict["AgentID"].ToString()); member.AgentID = value.ToString();
else else
member.AgentID = UUID.Zero.ToString(); member.AgentID = UUID.ZeroString;
if (dict.ContainsKey("AgentPowers") && dict["AgentPowers"] != null) if (dict.TryGetValue("AgentPowers", out value) && value != null)
member.AgentPowers = UInt64.Parse(dict["AgentPowers"].ToString()); member.AgentPowers = ulong.Parse(value.ToString());
if (dict.ContainsKey("Contribution") && dict["Contribution"] != null) if (dict.TryGetValue("Contribution", out value) && value != null)
member.Contribution = Int32.Parse(dict["Contribution"].ToString()); member.Contribution = int.Parse(value.ToString());
if (dict.ContainsKey("IsOwner") && dict["IsOwner"] != null) if (dict.TryGetValue("IsOwner", out value) && value != null)
member.IsOwner = bool.Parse(dict["IsOwner"].ToString()); member.IsOwner = bool.Parse(value.ToString());
if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null) if (dict.TryGetValue("ListInProfile", out value) && value != null)
member.ListInProfile = bool.Parse(dict["ListInProfile"].ToString()); member.ListInProfile = bool.Parse(value.ToString());
if (dict.ContainsKey("OnlineStatus") && dict["OnlineStatus"] != null) if (dict.TryGetValue("OnlineStatus", out value) && value != null)
member.OnlineStatus = Sanitize(dict["OnlineStatus"].ToString()); member.OnlineStatus = value.ToString();
else else
member.OnlineStatus = string.Empty; member.OnlineStatus = string.Empty;
if (dict.ContainsKey("Title") && dict["Title"] != null) if (dict.TryGetValue("Title", out value) && value != null)
member.Title = Sanitize(dict["Title"].ToString()); member.Title = value.ToString();
else else
member.Title = string.Empty; member.Title = string.Empty;
@@ -371,123 +375,116 @@ namespace OpenSim.Groups
if (dict == null) if (dict == null)
return role; return role;
if (dict.ContainsKey("Description") && dict["Description"] != null) object value;
role.Description = Sanitize(dict["Description"].ToString()); if (dict.TryGetValue("Description", out value) && value != null)
role.Description = value.ToString();
else else
role.Description = string.Empty; role.Description = string.Empty;
if (dict.ContainsKey("Members") && dict["Members"] != null) if (dict.TryGetValue("Members", out value) && value != null)
role.Members = Int32.Parse(dict["Members"].ToString()); role.Members = int.Parse(value.ToString());
if (dict.ContainsKey("Name") && dict["Name"] != null) if (dict.TryGetValue("Name", out value) && value != null)
role.Name = Sanitize(dict["Name"].ToString()); role.Name = value.ToString();
else else
role.Name = string.Empty; role.Name = string.Empty;
if (dict.ContainsKey("Powers") && dict["Powers"] != null) if (dict.TryGetValue("Powers", out value) && value != null)
role.Powers = UInt64.Parse(dict["Powers"].ToString()); role.Powers = ulong.Parse(value.ToString());
if (dict.ContainsKey("Title") && dict["Title"] != null) if (dict.TryGetValue("Title", out value) && value != null)
role.Title = Sanitize(dict["Title"].ToString()); role.Title = value.ToString();
else else
role.Title = string.Empty; role.Title = string.Empty;
if (dict.ContainsKey("RoleID") && dict["RoleID"] != null) if (dict.TryGetValue("RoleID", out value) && value != null)
role.RoleID = UUID.Parse(dict["RoleID"].ToString()); role.RoleID = UUID.Parse(value.ToString());
return role; return role;
} }
public static Dictionary<string, object> GroupRoleMembersData(ExtendedGroupRoleMembersData rmember) public static Dictionary<string, object> GroupRoleMembersData(ExtendedGroupRoleMembersData rmember)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); return new Dictionary<string, object>()
{
dict["RoleID"] = rmember.RoleID.ToString(); ["RoleID"] = rmember.RoleID.ToString(),
dict["MemberID"] = rmember.MemberID; ["MemberID"] = rmember.MemberID
return dict; };
} }
public static ExtendedGroupRoleMembersData GroupRoleMembersData(Dictionary<string, object> dict) public static ExtendedGroupRoleMembersData GroupRoleMembersData(Dictionary<string, object> dict)
{ {
ExtendedGroupRoleMembersData rmember = new ExtendedGroupRoleMembersData(); ExtendedGroupRoleMembersData rmember = new ExtendedGroupRoleMembersData();
if (dict.ContainsKey("RoleID") && dict["RoleID"] != null) object value;
rmember.RoleID = new UUID(dict["RoleID"].ToString()); if (dict.TryGetValue("RoleID", out value) && value != null)
rmember.RoleID = new UUID(value.ToString());
if (dict.ContainsKey("MemberID") && dict["MemberID"] != null) if (dict.TryGetValue("MemberID", out value) && value != null)
rmember.MemberID = dict["MemberID"].ToString(); rmember.MemberID = value.ToString();
return rmember; return rmember;
} }
public static Dictionary<string, object> GroupInviteInfo(GroupInviteInfo invite) public static Dictionary<string, object> GroupInviteInfo(GroupInviteInfo invite)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); return new Dictionary<string, object>()
{
dict["InviteID"] = invite.InviteID.ToString(); ["InviteID"] = invite.InviteID.ToString(),
dict["GroupID"] = invite.GroupID.ToString(); ["GroupID"] = invite.GroupID.ToString(),
dict["RoleID"] = invite.RoleID.ToString(); ["RoleID"] = invite.RoleID.ToString(),
dict["AgentID"] = invite.AgentID; ["AgentID"] = invite.AgentID
};
return dict;
} }
public static GroupInviteInfo GroupInviteInfo(Dictionary<string, object> dict) public static GroupInviteInfo GroupInviteInfo(Dictionary<string, object> dict)
{ {
if (dict == null) return dict == null ? null :
return null; new GroupInviteInfo
{
GroupInviteInfo invite = new GroupInviteInfo(); InviteID = new UUID(dict["InviteID"].ToString()),
GroupID = new UUID(dict["GroupID"].ToString()),
invite.InviteID = new UUID(dict["InviteID"].ToString()); RoleID = new UUID(dict["RoleID"].ToString()),
invite.GroupID = new UUID(dict["GroupID"].ToString()); AgentID = Sanitize(dict["AgentID"].ToString())
invite.RoleID = new UUID(dict["RoleID"].ToString()); };
invite.AgentID = Sanitize(dict["AgentID"].ToString());
return invite;
} }
public static Dictionary<string, object> GroupNoticeData(ExtendedGroupNoticeData notice) public static Dictionary<string, object> GroupNoticeData(ExtendedGroupNoticeData notice)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); return new Dictionary<string, object>
{
dict["NoticeID"] = notice.NoticeID.ToString(); ["NoticeID"] = notice.NoticeID.ToString(),
dict["Timestamp"] = notice.Timestamp.ToString(); ["Timestamp"] = notice.Timestamp.ToString(),
dict["FromName"] = Sanitize(notice.FromName); ["FromName"] = Sanitize(notice.FromName),
dict["Subject"] = Sanitize(notice.Subject); ["Subject"] = Sanitize(notice.Subject),
dict["HasAttachment"] = notice.HasAttachment.ToString(); ["HasAttachment"] = notice.HasAttachment.ToString(),
dict["AttachmentItemID"] = notice.AttachmentItemID.ToString(); ["AttachmentItemID"] = notice.AttachmentItemID.ToString(),
dict["AttachmentName"] = Sanitize(notice.AttachmentName); ["AttachmentName"] = Sanitize(notice.AttachmentName),
dict["AttachmentType"] = notice.AttachmentType.ToString(); ["AttachmentType"] = notice.AttachmentType.ToString(),
dict["AttachmentOwnerID"] = Sanitize(notice.AttachmentOwnerID); ["AttachmentOwnerID"] = Sanitize(notice.AttachmentOwnerID)
};
return dict;
} }
public static ExtendedGroupNoticeData GroupNoticeData(Dictionary<string, object> dict) public static ExtendedGroupNoticeData GroupNoticeData(Dictionary<string, object> dict)
{ {
ExtendedGroupNoticeData notice = new ExtendedGroupNoticeData(); return dict == null ? new ExtendedGroupNoticeData() :
new ExtendedGroupNoticeData()
if (dict == null) {
return notice; NoticeID = new UUID(dict["NoticeID"].ToString()),
Timestamp = uint.Parse(dict["Timestamp"].ToString()),
notice.NoticeID = new UUID(dict["NoticeID"].ToString()); FromName = Sanitize(dict["FromName"].ToString()),
notice.Timestamp = UInt32.Parse(dict["Timestamp"].ToString()); Subject = Sanitize(dict["Subject"].ToString()),
notice.FromName = Sanitize(dict["FromName"].ToString()); HasAttachment = bool.Parse(dict["HasAttachment"].ToString()),
notice.Subject = Sanitize(dict["Subject"].ToString()); AttachmentItemID = new UUID(dict["AttachmentItemID"].ToString()),
notice.HasAttachment = bool.Parse(dict["HasAttachment"].ToString()); AttachmentName = dict["AttachmentName"].ToString(),
notice.AttachmentItemID = new UUID(dict["AttachmentItemID"].ToString()); AttachmentType = byte.Parse(dict["AttachmentType"].ToString()),
notice.AttachmentName = dict["AttachmentName"].ToString(); AttachmentOwnerID = dict["AttachmentOwnerID"].ToString()
notice.AttachmentType = byte.Parse(dict["AttachmentType"].ToString()); };
notice.AttachmentOwnerID = dict["AttachmentOwnerID"].ToString(); }
return notice;
}
public static Dictionary<string, object> GroupNoticeInfo(GroupNoticeInfo notice) public static Dictionary<string, object> GroupNoticeInfo(GroupNoticeInfo notice)
{ {
Dictionary<string, object> dict = GroupNoticeData(notice.noticeData); Dictionary<string, object> dict = GroupNoticeData(notice.noticeData);
dict["GroupID"] = notice.GroupID.ToString(); dict["GroupID"] = notice.GroupID.ToString();
dict["Message"] = Sanitize(notice.Message); dict["Message"] = Sanitize(notice.Message);
@@ -496,25 +493,23 @@ namespace OpenSim.Groups
public static GroupNoticeInfo GroupNoticeInfo(Dictionary<string, object> dict) public static GroupNoticeInfo GroupNoticeInfo(Dictionary<string, object> dict)
{ {
GroupNoticeInfo notice = new GroupNoticeInfo(); return new GroupNoticeInfo
{
notice.noticeData = GroupNoticeData(dict); noticeData = GroupNoticeData(dict),
notice.GroupID = new UUID(dict["GroupID"].ToString()); GroupID = new UUID(dict["GroupID"].ToString()),
notice.Message = Sanitize(dict["Message"].ToString()); Message = Sanitize(dict["Message"].ToString())
};
return notice;
} }
public static Dictionary<string, object> DirGroupsReplyData(DirGroupsReplyData g) public static Dictionary<string, object> DirGroupsReplyData(DirGroupsReplyData g)
{ {
Dictionary<string, object> dict = new Dictionary<string, object>(); return new Dictionary<string, object>
{
dict["GroupID"] = g.groupID; ["GroupID"] = g.groupID,
dict["Name"] = g.groupName; ["Name"] = g.groupName,
dict["NMembers"] = g.members; ["NMembers"] = g.members,
dict["SearchOrder"] = g.searchOrder; ["SearchOrder"] = g.searchOrder
};
return dict;
} }
public static DirGroupsReplyData DirGroupsReplyData(Dictionary<string, object> dict) public static DirGroupsReplyData DirGroupsReplyData(Dictionary<string, object> dict)
@@ -523,7 +518,7 @@ namespace OpenSim.Groups
g.groupID = new UUID(dict["GroupID"].ToString()); g.groupID = new UUID(dict["GroupID"].ToString());
g.groupName = dict["Name"].ToString(); g.groupName = dict["Name"].ToString();
Int32.TryParse(dict["NMembers"].ToString(), out g.members); int.TryParse(dict["NMembers"].ToString(), out g.members);
float.TryParse(dict["SearchOrder"].ToString(), out g.searchOrder); float.TryParse(dict["SearchOrder"].ToString(), out g.searchOrder);
return g; return g;

View File

@@ -128,11 +128,10 @@ namespace OpenSim.Groups
Dictionary<string, object> request = Dictionary<string, object> request =
ServerUtils.ParseQueryString(body); ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD")) if(!request.Remove("METHOD", out object omethod))
return FailureResult(); return FailureResult();
string method = request["METHOD"].ToString(); string method = omethod.ToString();
request.Remove("METHOD");
m_log.DebugFormat("[Groups.RobustHGConnector]: {0}", method); m_log.DebugFormat("[Groups.RobustHGConnector]: {0}", method);
switch (method) switch (method)

View File

@@ -246,6 +246,7 @@ namespace OpenSim.Framework
/// <param name="b"></param> /// <param name="b"></param>
/// <param name="c"></param> /// <param name="c"></param>
/// <returns></returns> /// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double lerp(double a, double b, double c) public static double lerp(double a, double b, double c)
{ {
return (b * a) + (c * (1 - a)); return (b * a) + (c * (1 - a));
@@ -424,6 +425,7 @@ namespace OpenSim.Framework
// legacy, do not use // legacy, do not use
public static Random RandomClass public static Random RandomClass
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return Random.Shared;} get { return Random.Shared;}
} }

View File

@@ -305,11 +305,8 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
lock(dropedResponses) lock(dropedResponses)
{ {
if(dropedResponses.Contains(requestID)) if(dropedResponses.Remove(requestID))
{
dropedResponses.Remove(requestID);
return; return;
}
} }
} }
@@ -321,9 +318,8 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
lock(dropedResponses) lock(dropedResponses)
{ {
if(dropedResponses.Contains(requestID)) if(dropedResponses.Remove(requestID))
{ {
dropedResponses.Remove(requestID);
ProcessedRequestsCount++; ProcessedRequestsCount++;
return; return;
} }

View File

@@ -32,6 +32,7 @@ using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using log4net; using log4net;
using OpenSim.Framework.Monitoring; using OpenSim.Framework.Monitoring;
using System.Runtime.InteropServices;
namespace OpenSim.Region.ClientStack.LindenUDP namespace OpenSim.Region.ClientStack.LindenUDP
{ {
@@ -114,29 +115,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public Packet GetPacket(PacketType type) public Packet GetPacket(PacketType type)
{ {
PacketsRequested++; PacketsRequested++;
Packet packet;
if (!RecyclePackets) if (!RecyclePackets)
return Packet.BuildPacket(type); return Packet.BuildPacket(type);
Packet packet;
lock (pool) lock (pool)
{ {
if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0) if (!pool.TryGetValue(type, out Stack<Packet> typePacketsStack) || typePacketsStack == null || typePacketsStack.Count == 0)
{ {
// m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type); //m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
// Creating a new packet if we cannot reuse an old package
packet = Packet.BuildPacket(type); packet = Packet.BuildPacket(type);
} }
else else
{ {
// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type); //m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
// Recycle old packages // Recycle old packages
PacketsReused++; PacketsReused++;
packet = typePacketsStack.Pop();
packet = pool[type].Pop();
} }
} }
@@ -199,7 +195,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!RecyclePackets) if (!RecyclePackets)
return; return;
bool trypool = false;
PacketType type = packet.Type; PacketType type = packet.Type;
switch (type) switch (type)
@@ -207,83 +202,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case PacketType.ObjectUpdate: case PacketType.ObjectUpdate:
ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
oup.ObjectData = null; oup.ObjectData = null;
trypool = true;
break; break;
case PacketType.ImprovedTerseObjectUpdate: case PacketType.ImprovedTerseObjectUpdate:
ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
itoup.ObjectData = null; itoup.ObjectData = null;
trypool = true;
break; break;
case PacketType.PacketAck: case PacketType.PacketAck:
PacketAckPacket ackup = (PacketAckPacket)packet; PacketAckPacket ackup = (PacketAckPacket)packet;
ackup.Packets = null; ackup.Packets = null;
trypool = true;
break; break;
case PacketType.AgentUpdate:
trypool = true;
break;
default: default:
return; return;
} }
if(!trypool)
return;
lock (pool) lock (pool)
{ {
if (!pool.ContainsKey(type)) ref Stack<Packet> spkt = ref CollectionsMarshal.GetValueRefOrAddDefault(pool, type, out bool exists);
if (exists && spkt.Count < 50)
{ {
pool[type] = new Stack<Packet>(); spkt.Push(packet);
return;
} }
if ((pool[type]).Count < 50) spkt = new Stack<Packet>();
{ spkt.Push(packet);
// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
pool[type].Push(packet);
}
}
}
public T GetDataBlock<T>() where T: new()
{
lock (DataBlocks)
{
BlocksRequested++;
Stack<Object> s;
if (DataBlocks.TryGetValue(typeof(T), out s))
{
if (s.Count > 0)
{
BlocksReused++;
return (T)s.Pop();
}
}
else
{
DataBlocks[typeof(T)] = new Stack<Object>();
}
return new T();
}
}
public void ReturnDataBlock<T>(T block) where T: new()
{
if (block == null)
return;
lock (DataBlocks)
{
if (!DataBlocks.ContainsKey(typeof(T)))
DataBlocks[typeof(T)] = new Stack<Object>();
if (DataBlocks[typeof(T)].Count < 50)
DataBlocks[typeof(T)].Push(block);
} }
} }
} }

View File

@@ -528,7 +528,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// Create a new asset for user // Create a new asset for user
AssetBase asset = new AssetBase( AssetBase asset = new AssetBase(
UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture, UUID.Random(), "DynamicImage" + Random.Shared.Next(1, 10000), (sbyte)AssetType.Texture,
part.OwnerID.ToString()); part.OwnerID.ToString());
asset.Data = assetData; asset.Data = assetData;
asset.Description = string.Format("URL image : {0}", Url); asset.Description = string.Format("URL image : {0}", Url);

View File

@@ -253,7 +253,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
m_hasGroupChanged = value; m_hasGroupChanged = value;
//m_log.DebugFormat( //m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId); // "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId);
} }

View File

@@ -29,6 +29,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
@@ -147,15 +148,14 @@ namespace OpenSim.Region.DataSnapshot
#region Response storage #region Response storage
public XmlNode GetScene(Scene scene, XmlDocument factory) public XmlNode GetScene(Scene scene, XmlDocument factory)
{ {
m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName); m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.Name);
if (!m_scenes.ContainsKey(scene)) { ref bool sceneStale = ref CollectionsMarshal.GetValueRefOrAddDefault(m_scenes, scene, out bool exists);
m_scenes.Add(scene, true); //stale by default sceneStale |= !exists;
}
XmlNode regionElement = null; XmlNode regionElement = null;
if (!m_scenes[scene]) if (!sceneStale)
{ {
m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache.");
//get snapshot from cache //get snapshot from cache
@@ -212,7 +212,7 @@ namespace OpenSim.Region.DataSnapshot
m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message); m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message);
} }
m_scenes[scene] = false; sceneStale = false;
m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName);
} }
@@ -258,7 +258,6 @@ namespace OpenSim.Region.DataSnapshot
//attr.Value = scene.LandManager.landList.Count.ToString(); //attr.Value = scene.LandManager.landList.Count.ToString();
//docElement.Attributes.Append(attr); //docElement.Attributes.Append(attr);
XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", "");
XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", "");

View File

@@ -2942,7 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(obj is OTOpndBinOp) if(obj is OTOpndBinOp)
sb.Append(')'); sb.Append(')');
sb.Append('.'); sb.Append('.');
sb.Append(field.Name); sb.Append(this.field.Name);
return sb.ToString(); return sb.ToString();
} }
} }
@@ -3548,9 +3548,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{ {
get get
{ {
if(field.DeclaringType == typeof(ScriptBaseClass)) if(this.field.DeclaringType == typeof(ScriptBaseClass))
return field.Name; return this.field.Name;
return field.DeclaringType.Name + "." + field.Name; return this.field.DeclaringType.Name + "." + this.field.Name;
} }
} }
} }

View File

@@ -450,9 +450,11 @@ namespace OpenSim.Services.LLLoginService
// //
// Authenticate this user // Authenticate this user
// //
if (!passwd.StartsWith("$1$")) if (passwd.StartsWith("$1$"))
passwd = "$1$" + Util.Md5Hash(passwd); passwd = passwd[3..];
passwd = passwd.Remove(0, 3); //remove $1$ else
passwd = Util.Md5Hash(passwd);
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out UUID realID); string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out UUID realID);
UUID secureSession = UUID.Zero; UUID secureSession = UUID.Zero;
if (string.IsNullOrWhiteSpace(token) || !UUID.TryParse(token, out secureSession)) if (string.IsNullOrWhiteSpace(token) || !UUID.TryParse(token, out secureSession))