From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Framework/PermissionsUtil.cs | 57 +++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/PermissionsUtil.cs') diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs index d785a78..e50d4df 100644 --- a/OpenSim/Framework/PermissionsUtil.cs +++ b/OpenSim/Framework/PermissionsUtil.cs @@ -60,28 +60,57 @@ namespace OpenSim.Framework str += "C"; if ((perms & (int)PermissionMask.Transfer) != 0) str += "T"; + if ((perms & (int)PermissionMask.Export) != 0) + str += "X"; if (str == "") str = "."; return str; } - /// - /// Applies an object's folded permissions to its regular permissions. - /// - /// The folded permissions. Only the lowest 7 bits are examined. - /// The permissions variable to modify. - public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) + public static void ApplyFoldedPermissions(uint foldedSourcePerms, ref uint targetPerms) + { + uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask; + if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do + return; + + folded <<= (int)PermissionMask.FoldingShift; + folded |= ~(uint)PermissionMask.UnfoldedMask; + + uint tmp = targetPerms; + tmp &= folded; + targetPerms = tmp; + } + + // do not touch MOD + public static void ApplyNoModFoldedPermissions(uint foldedSourcePerms, ref uint target) { - if ((foldedPerms & 7) == 0) - return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded + uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask; + if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do + return; - if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Copy; - if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Transfer; - if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Modify; + folded <<= (int)PermissionMask.FoldingShift; + folded |= (~(uint)PermissionMask.UnfoldedMask | (uint)PermissionMask.Modify); + + uint tmp = target; + tmp &= folded; + target = tmp; } + public static uint FixAndFoldPermissions(uint perms) + { + uint tmp = perms; + + // C & T rule + if((tmp & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0) + tmp |= (uint)PermissionMask.Transfer; + + // unlock + tmp |= (uint)PermissionMask.Move; + + tmp &= ~(uint)PermissionMask.FoldedMask; + tmp |= ((tmp >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask); + + return tmp; + } } } -- cgit v1.1