29 using System.Collections.Generic;
30 using System.Reflection;
35 using OpenMetaverse.Packets;
36 using OpenSim.Framework;
37 using OpenSim.Region.Framework;
38 using OpenSim.Region.Framework.Interfaces;
39 using OpenSim.Region.Framework.Scenes;
40 using OpenSim.Region.Framework.Scenes.Serialization;
45 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"BuySellModule")]
53 public string Name {
get {
return "Object BuySell Module"; } }
54 public Type ReplaceableInterface {
get {
return null; } }
62 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
67 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
72 m_dialogModule = scene.RequestModuleInterface<
IDialogModule>();
77 RemoveRegion(m_scene);
86 IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType,
int salePrice)
98 part = part.ParentGroup.RootPart;
100 part.ObjectSaleType = saleType;
101 part.SalePrice = salePrice;
103 part.ParentGroup.HasGroupChanged =
true;
105 part.SendPropertiesToClient(client);
108 public bool BuyObject(
IClientAPI remoteClient, UUID categoryID, uint localID, byte saleType,
int salePrice)
120 uint effectivePerms = group.GetEffectivePermissions();
122 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
124 if (m_dialogModule != null)
125 m_dialogModule.SendAlertToUser(remoteClient,
"This item doesn't appear to be for sale");
129 group.SetOwnerId(remoteClient.AgentId);
130 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
132 if (m_scene.Permissions.PropagatePermissions())
136 child.Inventory.ChangeInventoryOwner(remoteClient.AgentId);
137 child.TriggerScriptChangedEvent(Changed.OWNER);
138 child.ApplyNextOwnerPermissions();
142 part.ObjectSaleType = 0;
144 part.ClickAction = Convert.ToByte(0);
146 group.HasGroupChanged =
true;
147 part.SendPropertiesToClient(remoteClient);
148 part.TriggerScriptChangedEvent(Changed.OWNER);
149 group.ResumeScripts();
150 part.ScheduleFullUpdate();
155 Vector3 inventoryStoredPosition =
new Vector3(
157 Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
160 Vector3 originalPosition = group.AbsolutePosition;
162 group.AbsolutePosition = inventoryStoredPosition;
164 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
165 group.AbsolutePosition = originalPosition;
167 uint perms = group.GetEffectivePermissions();
169 if ((perms & (uint)PermissionMask.Transfer) == 0)
171 if (m_dialogModule != null)
172 m_dialogModule.SendAlertToUser(remoteClient,
"This item doesn't appear to be for sale");
176 if ((perms & (uint)PermissionMask.Copy) == 0)
178 if (m_dialogModule != null)
179 m_dialogModule.SendAlertToUser(remoteClient,
"This sale has been blocked by the permissions system");
184 group.GetPartName(localID),
186 (sbyte)AssetType.Object,
187 Utils.StringToBytes(sceneObjectXml),
189 m_scene.AssetService.Store(asset);
192 item.CreatorId = part.CreatorID.ToString();
193 item.CreatorData = part.CreatorData;
195 item.ID = UUID.Random();
196 item.Owner = remoteClient.AgentId;
197 item.AssetID = asset.FullID;
198 item.Description = asset.Description;
199 item.Name = asset.Name;
200 item.AssetType = asset.Type;
201 item.InvType = (int)InventoryType.Object;
202 item.Folder = categoryID;
204 PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
206 item.BasePermissions = perms & part.NextOwnerMask;
207 item.CurrentPermissions = perms & part.NextOwnerMask;
208 item.NextPermissions = part.NextOwnerMask;
209 item.EveryOnePermissions = part.EveryoneMask &
211 item.GroupPermissions = part.GroupMask &
213 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
214 item.CreationDate = Util.UnixTimeSinceEpoch();
216 if (m_scene.AddInventoryItem(item))
218 remoteClient.SendInventoryItemCreateUpdate(item, 0);
222 if (m_dialogModule != null)
223 m_dialogModule.SendAlertToUser(remoteClient,
"Cannot buy now. Your inventory is unavailable");
229 List<UUID> invList = part.Inventory.GetInventoryList();
231 bool okToSell =
true;
233 foreach (
UUID invID
in invList)
237 (uint)PermissionMask.Transfer) == 0)
246 if (m_dialogModule != null)
247 m_dialogModule.SendAlertToUser(
248 remoteClient,
"This item's inventory doesn't appear to be for sale");
252 if (invList.Count > 0)
253 m_scene.MoveTaskInventoryItems(remoteClient.AgentId, part.Name, part, invList);
delegate void ObjectSaleInfo(IClientAPI remoteClient, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice)
OpenSim.Server.Handlers.Simulation.Utils Utils
void SubscribeToClientEvents(IClientAPI client)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Represents an item in a task inventory
bool BuyObject(IClientAPI remoteClient, UUID categoryID, uint localID, byte saleType, int salePrice)
Try to buy an object
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
bool IsDeleted
Signals whether this entity was in a scene but has since been removed from it.
Asset class. All Assets are reference by this class or a class derived from this class ...
OpenSim.Framework.PermissionMask PermissionMask
Inventory Item - contains all the properties associated with an individual inventory piece...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Interactive OpenSim region server
SceneObjectGroup ParentGroup
void ObjectSaleInfo(IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice)
override Vector3 AbsolutePosition
The absolute position of this scene object in the scene
string GetPartDescription(uint localID)
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
IDialogModule m_dialogModule