aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs92
1 files changed, 52 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2abc910..6a8f4c0 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -45,38 +45,38 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BuySellModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BuySellModule")]
46 public class BuySellModule : IBuySellModule, INonSharedRegionModule 46 public class BuySellModule : IBuySellModule, INonSharedRegionModule
47 { 47 {
48// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 protected Scene m_scene = null; 50 protected Scene m_scene = null;
51 protected IDialogModule m_dialogModule; 51 protected IDialogModule m_dialogModule;
52 52
53 public string Name { get { return "Object BuySell Module"; } } 53 public string Name { get { return "Object BuySell Module"; } }
54 public Type ReplaceableInterface { get { return null; } } 54 public Type ReplaceableInterface { get { return null; } }
55 55
56 public void Initialise(IConfigSource source) {} 56 public void Initialise(IConfigSource source) {}
57 57
58 public void AddRegion(Scene scene) 58 public void AddRegion(Scene scene)
59 { 59 {
60 m_scene = scene; 60 m_scene = scene;
61 m_scene.RegisterModuleInterface<IBuySellModule>(this); 61 m_scene.RegisterModuleInterface<IBuySellModule>(this);
62 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 62 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
63 } 63 }
64 64
65 public void RemoveRegion(Scene scene) 65 public void RemoveRegion(Scene scene)
66 { 66 {
67 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; 67 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
68 } 68 }
69 69
70 public void RegionLoaded(Scene scene) 70 public void RegionLoaded(Scene scene)
71 { 71 {
72 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 72 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
73 } 73 }
74 74
75 public void Close() 75 public void Close()
76 { 76 {
77 RemoveRegion(m_scene); 77 RemoveRegion(m_scene);
78 } 78 }
79 79
80 public void SubscribeToClientEvents(IClientAPI client) 80 public void SubscribeToClientEvents(IClientAPI client)
81 { 81 {
82 client.OnObjectSaleInfo += ObjectSaleInfo; 82 client.OnObjectSaleInfo += ObjectSaleInfo;
@@ -89,18 +89,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
89 if (part == null) 89 if (part == null)
90 return; 90 return;
91 91
92 if (part.ParentGroup.IsDeleted) 92 SceneObjectGroup sog = part.ParentGroup;
93 if (sog == null || sog.IsDeleted)
93 return; 94 return;
94 95
95 if (part.OwnerID != client.AgentId && (!m_scene.Permissions.IsGod(client.AgentId))) 96 // Does the user have the power to put the object on sale?
97 if (!m_scene.Permissions.CanSellObject(client, sog, saleType))
98 {
99 client.SendAgentAlertMessage("You don't have permission to set object on sale", false);
96 return; 100 return;
101 }
97 102
98 part = part.ParentGroup.RootPart; 103 part = sog.RootPart;
99 104
100 part.ObjectSaleType = saleType; 105 part.ObjectSaleType = saleType;
101 part.SalePrice = salePrice; 106 part.SalePrice = salePrice;
102 107
103 part.ParentGroup.HasGroupChanged = true; 108 sog.HasGroupChanged = true;
104 109
105 part.SendPropertiesToClient(client); 110 part.SendPropertiesToClient(client);
106 } 111 }
@@ -113,11 +118,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
113 return false; 118 return false;
114 119
115 SceneObjectGroup group = part.ParentGroup; 120 SceneObjectGroup group = part.ParentGroup;
121 if(group == null || group.IsDeleted || group.inTransit)
122 return false;
123
124 // make sure we are not buying a child part
125 part = group.RootPart;
116 126
117 switch (saleType) 127 switch (saleType)
118 { 128 {
119 case 1: // Sell as original (in-place sale) 129 case 1: // Sell as original (in-place sale)
120 uint effectivePerms = group.GetEffectivePermissions(); 130 uint effectivePerms = group.EffectiveOwnerPerms;
121 131
122 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
123 { 133 {
@@ -126,8 +136,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
126 return false; 136 return false;
127 } 137 }
128 138
129 group.SetOwnerId(remoteClient.AgentId); 139 group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
130 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
131 140
132 if (m_scene.Permissions.PropagatePermissions()) 141 if (m_scene.Permissions.PropagatePermissions())
133 { 142 {
@@ -137,6 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
137 child.TriggerScriptChangedEvent(Changed.OWNER); 146 child.TriggerScriptChangedEvent(Changed.OWNER);
138 child.ApplyNextOwnerPermissions(); 147 child.ApplyNextOwnerPermissions();
139 } 148 }
149 group.InvalidateDeepEffectivePerms();
140 } 150 }
141 151
142 part.ObjectSaleType = 0; 152 part.ObjectSaleType = 0;
@@ -152,19 +162,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
152 break; 162 break;
153 163
154 case 2: // Sell a copy 164 case 2: // Sell a copy
155 Vector3 inventoryStoredPosition = new Vector3( 165 uint perms = group.EffectiveOwnerPerms;
156 Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6),
157 Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
158 group.AbsolutePosition.Z);
159
160 Vector3 originalPosition = group.AbsolutePosition;
161
162 group.AbsolutePosition = inventoryStoredPosition;
163
164 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
165 group.AbsolutePosition = originalPosition;
166
167 uint perms = group.GetEffectivePermissions();
168 166
169 if ((perms & (uint)PermissionMask.Transfer) == 0) 167 if ((perms & (uint)PermissionMask.Transfer) == 0)
170 { 168 {
@@ -173,6 +171,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
173 return false; 171 return false;
174 } 172 }
175 173
174 if ((perms & (uint)PermissionMask.Copy) == 0)
175 {
176 if (m_dialogModule != null)
177 m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
178 return false;
179 }
180
181 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
182
176 AssetBase asset = m_scene.CreateAsset( 183 AssetBase asset = m_scene.CreateAsset(
177 group.GetPartName(localID), 184 group.GetPartName(localID),
178 group.GetPartDescription(localID), 185 group.GetPartDescription(localID),
@@ -193,16 +200,21 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
193 item.AssetType = asset.Type; 200 item.AssetType = asset.Type;
194 item.InvType = (int)InventoryType.Object; 201 item.InvType = (int)InventoryType.Object;
195 item.Folder = categoryID; 202 item.Folder = categoryID;
203
204 perms = group.CurrentAndFoldedNextPermissions();
205 // apply parts inventory next perms
206 PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms);
207 // change to next owner perms
208 perms &= part.NextOwnerMask;
209 // update folded
210 perms = PermissionsUtil.FixAndFoldPermissions(perms);
211
212 item.BasePermissions = perms;
213 item.CurrentPermissions = perms;
214 item.NextPermissions = part.NextOwnerMask & perms;
215 item.EveryOnePermissions = part.EveryoneMask & perms;
216 item.GroupPermissions = part.GroupMask & perms;
196 217
197 PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
198
199 item.BasePermissions = perms & part.NextOwnerMask;
200 item.CurrentPermissions = perms & part.NextOwnerMask;
201 item.NextPermissions = part.NextOwnerMask;
202 item.EveryOnePermissions = part.EveryoneMask &
203 part.NextOwnerMask;
204 item.GroupPermissions = part.GroupMask &
205 part.NextOwnerMask;
206 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 218 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
207 item.CreationDate = Util.UnixTimeSinceEpoch(); 219 item.CreationDate = Util.UnixTimeSinceEpoch();
208 220