aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-05 06:44:32 +0000
committerTeravus Ovares2007-12-05 06:44:32 +0000
commitbb824eadeeb2b35025954d0c97f15123c6fd0cbe (patch)
treeafca518b8e5b806cd2e7ab7965d34765d4b18bc4 /OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
parentfixed a few compiler warnings under mono (committed from a train, with adjohn... (diff)
downloadopensim-SC_OLD-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.zip
opensim-SC_OLD-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.gz
opensim-SC_OLD-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.bz2
opensim-SC_OLD-bb824eadeeb2b35025954d0c97f15123c6fd0cbe.tar.xz
* Refactored Permissions into ScenePresence as requested by MW
* Un-hackerized generating the client_flags * Now handling the ObjectPermissions Update packet * Warning: Backup your prim before updating. If you fail to do so and something goes wrong then, All Yr prim are belong to us!
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs270
1 files changed, 172 insertions, 98 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 19405fc..238e78a 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -44,8 +44,12 @@ namespace OpenSim.Region.Environment.Scenes
44{ 44{
45 public class SceneObjectPart : IScriptHost 45 public class SceneObjectPart : IScriptHost
46 { 46 {
47 private const uint FULL_MASK_PERMISSIONS = 2147483647; 47 private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer;
48 48 private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner;
49 private const uint OBJNEXT_OWNER = 2147483647;
50
51 private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
52 private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
49 private string m_inventoryFileName = ""; 53 private string m_inventoryFileName = "";
50 private LLUUID m_folderID = LLUUID.Zero; 54 private LLUUID m_folderID = LLUUID.Zero;
51 55
@@ -64,11 +68,13 @@ namespace OpenSim.Region.Environment.Scenes
64 public Int32 CreationDate; 68 public Int32 CreationDate;
65 public uint ParentID = 0; 69 public uint ParentID = 0;
66 70
67 public uint OwnerMask = FULL_MASK_PERMISSIONS; 71 // Main grid has default permissions as follows
68 public uint NextOwnerMask = FULL_MASK_PERMISSIONS; 72 //
69 public uint GroupMask = FULL_MASK_PERMISSIONS; 73 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
70 public uint EveryoneMask = FULL_MASK_PERMISSIONS; 74 public uint NextOwnerMask = OBJNEXT_OWNER;
71 public uint BaseMask = FULL_MASK_PERMISSIONS; 75 public uint GroupMask = (uint) LLObject.ObjectFlags.None;
76 public uint EveryoneMask = (uint) LLObject.ObjectFlags.None;
77 public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER;
72 78
73 protected byte[] m_particleSystem = new byte[0]; 79 protected byte[] m_particleSystem = new byte[0];
74 80
@@ -463,17 +469,11 @@ namespace OpenSim.Region.Environment.Scenes
463 m_folderID = LLUUID.Random(); 469 m_folderID = LLUUID.Random();
464 470
465 m_flags = 0; 471 m_flags = 0;
466 m_flags |= LLObject.ObjectFlags.ObjectModify | 472 m_flags |= LLObject.ObjectFlags.Touch |
467 LLObject.ObjectFlags.ObjectCopy | 473 LLObject.ObjectFlags.AllowInventoryDrop |
468 LLObject.ObjectFlags.ObjectYouOwner | 474 LLObject.ObjectFlags.CreateSelected;
469 LLObject.ObjectFlags.Touch | 475
470 LLObject.ObjectFlags.ObjectMove | 476 ApplySanePermissions();
471 LLObject.ObjectFlags.AllowInventoryDrop |
472 LLObject.ObjectFlags.ObjectTransfer |
473 LLObject.ObjectFlags.CreateSelected |
474 LLObject.ObjectFlags.ObjectOwnerModify;
475
476 ApplyPermissions();
477 477
478 ScheduleFullUpdate(); 478 ScheduleFullUpdate();
479 } 479 }
@@ -511,7 +511,7 @@ namespace OpenSim.Region.Environment.Scenes
511 RotationOffset = rotation; 511 RotationOffset = rotation;
512 ObjectFlags = flags; 512 ObjectFlags = flags;
513 513
514 ApplyPermissions(); 514 ApplySanePermissions();
515 // ApplyPhysics(); 515 // ApplyPhysics();
516 516
517 ScheduleFullUpdate(); 517 ScheduleFullUpdate();
@@ -552,24 +552,99 @@ namespace OpenSim.Region.Environment.Scenes
552 552
553 DoPhysicsPropertyUpdate(usePhysics, true); 553 DoPhysicsPropertyUpdate(usePhysics, true);
554 } 554 }
555 public void ApplyNextOwnerPermissions()
556 {
557 BaseMask = NextOwnerMask;
558 OwnerMask = NextOwnerMask;
559 }
560 public void ApplySanePermissions()
561 {
562 // These are some flags that The OwnerMask should never have
563 OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
564 OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
565 OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
566 OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
567 OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
568 OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
569 OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
570 OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
571 OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
572 OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
573 OwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
574 OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
575 OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
576 OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
577
578
579 // These are some flags that the next owner mask should never have
580 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
581 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
582 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
583 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
584 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
585 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
586 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
587 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
588 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
589 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
590 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
591 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
592 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
593 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
594 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
595 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
596 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
597
598
599 // These are some flags that the GroupMask should never have
600 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
601 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
602 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
603 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
604 GroupMask &= ~(uint)LLObject.ObjectFlags.Physics;
605 GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom;
606 GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted;
607 GroupMask &= ~(uint)LLObject.ObjectFlags.Touch;
608 GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary;
609 GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
610 GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
611 GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
612 GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
613 GroupMask &= ~(uint)LLObject.ObjectFlags.Money;
614 GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
615 GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
616 GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
617
618
619 // These are some flags that EveryoneMask should never have
620 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
621 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
622 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
623 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
624 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics;
625 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom;
626 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted;
627 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch;
628 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary;
629 EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
630 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
631 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
632 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
633 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money;
634 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
635 EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
636 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
637
638
639 // These are some flags that ObjectFlags (m_flags) should never have
640 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
641 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
642 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
643 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
644 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
645 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
646 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
555 647
556 public void ApplyPermissions()
557 {
558 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
559 {
560 EveryoneMask = ObjectFlags;
561 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
562 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
563 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
564 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
565 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
566 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
567 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
568 }
569 else
570 {
571 EveryoneMask = ObjectFlags;
572 }
573 } 648 }
574 649
575 /// <summary> 650 /// <summary>
@@ -774,9 +849,7 @@ namespace OpenSim.Region.Environment.Scenes
774 { 849 {
775 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); 850 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
776 m_flags |= flag; 851 m_flags |= flag;
777 BaseMask |= (uint)flag; 852
778 GroupMask |= (uint)flag;
779 EveryoneMask |= (uint)flag;
780 } 853 }
781 uint currflag = (uint)m_flags; 854 uint currflag = (uint)m_flags;
782 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 855 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
@@ -790,9 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
790 { 863 {
791 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); 864 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
792 m_flags &= ~flag; 865 m_flags &= ~flag;
793 BaseMask &= ~(uint)flag; 866
794 GroupMask &= ~(uint)flag;
795 EveryoneMask &= ~(uint)flag;
796 } 867 }
797 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 868 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
798 //ScheduleFullUpdate(); 869 //ScheduleFullUpdate();
@@ -1198,6 +1269,51 @@ namespace OpenSim.Region.Environment.Scenes
1198 1269
1199 #endregion 1270 #endregion
1200 1271
1272 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1273 {
1274 // Are we the owner?
1275 if (AgentID == OwnerID)
1276 {
1277 MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString());
1278
1279 //Field 8 = EveryoneMask
1280 if (field == (byte)8)
1281 {
1282 MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask));
1283 if (addRemTF == (byte)0)
1284 {
1285 //EveryoneMask = (uint)0;
1286 EveryoneMask &= ~mask;
1287 //EveryoneMask &= ~(uint)57344;
1288
1289
1290 }
1291 else
1292 {
1293 //EveryoneMask = (uint)0;
1294 EveryoneMask |= mask;
1295 //EveryoneMask |= (uint)57344;
1296
1297 }
1298 ScheduleFullUpdate();
1299 }
1300 //Field 16 = NextownerMask
1301 if (field == (byte)16)
1302 {
1303 if (addRemTF == (byte)0)
1304 {
1305 NextOwnerMask &= ~mask;
1306 }
1307 else
1308 {
1309 NextOwnerMask |= mask;
1310 }
1311 ScheduleFullUpdate();
1312 }
1313
1314 }
1315 }
1316
1201 #region Client Update Methods 1317 #region Client Update Methods
1202 1318
1203 public void AddFullUpdateToAllAvatars() 1319 public void AddFullUpdateToAllAvatars()
@@ -1222,7 +1338,8 @@ namespace OpenSim.Region.Environment.Scenes
1222 List<ScenePresence> avatars = m_parentGroup.GetScenePresences(); 1338 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1223 for (int i = 0; i < avatars.Count; i++) 1339 for (int i = 0; i < avatars.Count; i++)
1224 { 1340 {
1225 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); 1341 // Ugly reference :(
1342 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID));
1226 } 1343 }
1227 } 1344 }
1228 1345
@@ -1230,20 +1347,20 @@ namespace OpenSim.Region.Environment.Scenes
1230 /// 1347 ///
1231 /// </summary> 1348 /// </summary>
1232 /// <param name="remoteClient"></param> 1349 /// <param name="remoteClient"></param>
1233 public void SendFullUpdate(IClientAPI remoteClient) 1350 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
1234 { 1351 {
1235 m_parentGroup.SendPartFullUpdate(remoteClient, this); 1352 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
1236 } 1353 }
1237 1354
1238 /// <summary> 1355 /// <summary>
1239 /// 1356 ///
1240 /// </summary> 1357 /// </summary>
1241 /// <param name="remoteClient"></param> 1358 /// <param name="remoteClient"></param>
1242 public void SendFullUpdateToClient(IClientAPI remoteClient) 1359 public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
1243 { 1360 {
1244 LLVector3 lPos; 1361 LLVector3 lPos;
1245 lPos = OffsetPosition; 1362 lPos = OffsetPosition;
1246 SendFullUpdateToClient(remoteClient, lPos); 1363 SendFullUpdateToClient(remoteClient, lPos, clientflags);
1247 } 1364 }
1248 1365
1249 /// <summary> 1366 /// <summary>
@@ -1251,56 +1368,13 @@ namespace OpenSim.Region.Environment.Scenes
1251 /// </summary> 1368 /// </summary>
1252 /// <param name="remoteClient"></param> 1369 /// <param name="remoteClient"></param>
1253 /// <param name="lPos"></param> 1370 /// <param name="lPos"></param>
1254 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) 1371 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
1255 { 1372 {
1256 LLQuaternion lRot; 1373 LLQuaternion lRot;
1257 lRot = RotationOffset; 1374 lRot = RotationOffset;
1258 uint clientFlags = ObjectFlags & ~(uint)LLObject.ObjectFlags.CreateSelected; 1375 if (remoteClient.AgentId == OwnerID)
1259
1260 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1261 foreach (ScenePresence s in avatars)
1262 { 1376 {
1263 if (s.m_uuid == OwnerID) 1377 clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected;
1264 {
1265 if (s.ControllingClient == remoteClient)
1266 {
1267 clientFlags = ObjectFlags;
1268 m_flags &= ~LLObject.ObjectFlags.CreateSelected;
1269 }
1270 break;
1271 }
1272 }
1273 // If you can't edit it, send the base permissions minus the flag to edit
1274
1275
1276 // We're going to be moving this into ScenePresence and the PermissionsManager itself.
1277 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
1278 {
1279 if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID))
1280 {
1281 // we should be merging the objectflags with the ownermask here.
1282 // TODO: Future refactoring here.
1283 clientFlags = ObjectFlags;
1284
1285 }
1286 else
1287 {
1288 //clientFlags = ObjectFlags;
1289 clientFlags = EveryoneMask;
1290 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID))
1291 {
1292 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
1293 }
1294
1295 if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID))
1296 {
1297 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
1298 }
1299
1300 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
1301 clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1302 clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1303 }
1304 } 1378 }
1305 1379
1306 1380
@@ -1479,11 +1553,11 @@ namespace OpenSim.Region.Environment.Scenes
1479 public LLUUID item_id = LLUUID.Zero; 1553 public LLUUID item_id = LLUUID.Zero;
1480 public LLUUID parent_id = LLUUID.Zero; //parent folder id 1554 public LLUUID parent_id = LLUUID.Zero; //parent folder id
1481 1555
1482 public uint base_mask = FULL_MASK_PERMISSIONS; 1556 public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL;
1483 public uint owner_mask = FULL_MASK_PERMISSIONS; 1557 public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
1484 public uint group_mask = FULL_MASK_PERMISSIONS; 1558 public uint group_mask = FULL_MASK_PERMISSIONS_GENERAL;
1485 public uint everyone_mask = FULL_MASK_PERMISSIONS; 1559 public uint everyone_mask = FULL_MASK_PERMISSIONS_GENERAL;
1486 public uint next_owner_mask = FULL_MASK_PERMISSIONS; 1560 public uint next_owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
1487 public LLUUID creator_id = LLUUID.Zero; 1561 public LLUUID creator_id = LLUUID.Zero;
1488 public LLUUID owner_id = LLUUID.Zero; 1562 public LLUUID owner_id = LLUUID.Zero;
1489 public LLUUID last_owner_id = LLUUID.Zero; 1563 public LLUUID last_owner_id = LLUUID.Zero;