aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorSean Dague2007-12-03 20:06:01 +0000
committerSean Dague2007-12-03 20:06:01 +0000
commit8f58a9a107047bf9d9aff4d8c25171acaa8e9805 (patch)
treebde9e5b6c29792d19c487549f99f198709e61bc8 /OpenSim/Region/Environment
parent* Now using interpolation to expand the 256x256 heightfield data to 512x512 b... (diff)
downloadopensim-SC-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.zip
opensim-SC-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.gz
opensim-SC-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.bz2
opensim-SC-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.xz
From Justin Casey (IBM)
While exploring what it would take to get the 'new script' button working, I encountered the fact, some way down in the rabbit hole, that if a user renamed an item in their inventory and logged out (without a restart of the simulator), on log in the new name was not preserved. As far as I can see, this was because any updates which didn't occur inside a transaction were ignored by opensim. This patch pays attention to those changes. It generates a new asset when an item is updated and changes the user's inventory properties appropriately. I believe this behaviour is in line with the copy-on-write semantics used in the Second Life protocol - perhaps it could be optimized if we knew for sure that the only copy of the object was in the user's inventory. This also means that if you rename an item (e.g. a script) before you drag it into an object's inventory, the inventory will receive the item's most recent name and description.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs119
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs2
2 files changed, 88 insertions, 33 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 1ea8d5a..5976fdc 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -106,53 +106,108 @@ namespace OpenSim.Region.Environment.Scenes
106 return LLUUID.Zero; 106 return LLUUID.Zero;
107 } 107 }
108 108
109 public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, 109 /// <summary>
110 LLUUID itemID) 110 /// Update an item which is either already in the client's inventory or is within
111 { 111 /// a transaction
112 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 112 /// </summary>
113 if (userInfo != null) 113 /// <param name="remoteClient"></param>
114 /// <param name="transactionID">The transaction ID. If this is LLUUID.Zero we will
115 /// assume that we are not in a transaction</param>
116 /// <param name="itemID">The ID of the updated item</param>
117 /// <param name="name">The name of the updated item</param>
118 /// <param name="description">The description of the updated item</param>
119 /// <param name="nextOwnerMask">The permissions of the updated item</param>
120 public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID,
121 LLUUID itemID, string name, string description,
122 uint nextOwnerMask)
123 {
124 CachedUserInfo userInfo
125 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
126
127 if (userInfo != null && userInfo.RootFolder != null)
114 { 128 {
115 if (userInfo.RootFolder != null) 129 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
130 if (item != null)
116 { 131 {
117 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 132 AssetBase asset = null;
118 if (item != null) 133 bool addAsset = false;
134
135 // If we're not inside a transaction and an existing asset is attached
136 // to the update item, then we need to create a new asset for the new details
137 if (LLUUID.Zero == transactionID)
138 {
139 asset = AssetCache.GetAsset(item.assetID);
140
141 if (asset != null)
142 {
143 // to update an item we need to create a new asset
144 // it's possible that this could be optimized to an update if we knew
145 // that the owner's inventory had the only copy of the item (I believe
146 // we're using copy on write semantics).
147 item.inventoryName = asset.Name = name;
148 item.inventoryDescription = asset.Description = description;
149 item.inventoryNextPermissions = nextOwnerMask;
150 item.assetID = asset.FullID = LLUUID.Random();
151
152 addAsset = true;
153 }
154 else
155 {
156 OpenSim.Framework.Console.MainLog.Instance.Warn(
157 "Asset ID " + item.assetID + " not found for item ID " + itemID
158 + " named " + item.inventoryName + " for an inventory item update.");
159 return;
160 }
161 }
162 else
119 { 163 {
120 AgentAssetTransactions transactions = 164 AgentAssetTransactions transactions
121 CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); 165 = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
166
122 if (transactions != null) 167 if (transactions != null)
123 { 168 {
124 AssetBase asset = null; 169 LLUUID assetID = transactionID.Combine(remoteClient.SecureSessionId);
125 bool addToCache = false;
126
127 asset = AssetCache.GetAsset(assetID); 170 asset = AssetCache.GetAsset(assetID);
171
128 if (asset == null) 172 if (asset == null)
129 { 173 {
130 asset = transactions.GetTransactionAsset(transactionID); 174 asset = transactions.GetTransactionAsset(transactionID);
131 addToCache = true;
132 } 175 }
133 176
134 if (asset != null) 177 if (asset != null && asset.FullID == assetID)
135 { 178 {
136 if (asset.FullID == assetID) 179 asset.Name = item.inventoryName;
137 { 180 asset.Description = item.inventoryDescription;
138 asset.Name = item.inventoryName; 181 asset.InvType = (sbyte) item.invType;
139 asset.Description = item.inventoryDescription; 182 asset.Type = (sbyte) item.assetType;
140 asset.InvType = (sbyte) item.invType; 183 item.assetID = asset.FullID;
141 asset.Type = (sbyte) item.assetType; 184
142 item.assetID = asset.FullID; 185 addAsset = true;
143
144 if (addToCache)
145 {
146 AssetCache.AddAsset(asset);
147 }
148
149 userInfo.UpdateItem(remoteClient.AgentId, item);
150 }
151 } 186 }
152 } 187 }
153 } 188 }
189
190 if (asset != null)
191 {
192 if (addAsset)
193 {
194 AssetCache.AddAsset(asset);
195 }
196
197 userInfo.UpdateItem(remoteClient.AgentId, item);
198 }
199 }
200 else
201 {
202 OpenSim.Framework.Console.MainLog.Instance.Warn(
203 "Item ID " + itemID + " not found for an inventory item update.");
154 } 204 }
155 } 205 }
206 else
207 {
208 OpenSim.Framework.Console.MainLog.Instance.Warn(
209 "Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
210 }
156 } 211 }
157 212
158 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) 213 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName)
@@ -507,4 +562,4 @@ namespace OpenSim.Region.Environment.Scenes
507 rootPart.ScheduleFullUpdate(); 562 rootPart.ScheduleFullUpdate();
508 } 563 }
509 } 564 }
510} \ No newline at end of file 565}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 09ecae0..8fc04c4 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -989,7 +989,7 @@ namespace OpenSim.Region.Environment.Scenes
989 client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents; 989 client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents;
990 client.OnRequestTaskInventory += RequestTaskInventory; 990 client.OnRequestTaskInventory += RequestTaskInventory;
991 client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory; 991 client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory;
992 client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; 992 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
993 client.OnCopyInventoryItem += CopyInventoryItem; 993 client.OnCopyInventoryItem += CopyInventoryItem;
994 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; 994 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
995 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; 995 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;