diff options
author | Diva Canto | 2012-04-06 11:52:05 -0700 |
---|---|---|
committer | Diva Canto | 2012-04-06 11:52:05 -0700 |
commit | 7435582b7040d46675adc3795aa0e39f28c6718b (patch) | |
tree | fbc9bf74ac24d76f3bf57ce54b5c9880b54baea9 /OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |
parent | WARNING: LOTS OF COMMENTED AND UNUSED CODE IN THIS COMMIT. This is on purpose... (diff) | |
download | opensim-SC_OLD-7435582b7040d46675adc3795aa0e39f28c6718b.zip opensim-SC_OLD-7435582b7040d46675adc3795aa0e39f28c6718b.tar.gz opensim-SC_OLD-7435582b7040d46675adc3795aa0e39f28c6718b.tar.bz2 opensim-SC_OLD-7435582b7040d46675adc3795aa0e39f28c6718b.tar.xz |
If an AddItem fails, try adding it to the right folder type.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 83 |
1 files changed, 63 insertions, 20 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5abd74f..10b25ed 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -36,6 +36,7 @@ using OpenMetaverse.Packets; | |||
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework; | 38 | using OpenSim.Region.Framework; |
39 | using OpenSim.Framework.Client; | ||
39 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
41 | 42 | ||
@@ -117,31 +118,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="item"></param> | 118 | /// <param name="item"></param> |
118 | public bool AddInventoryItem(InventoryItemBase item) | 119 | public bool AddInventoryItem(InventoryItemBase item) |
119 | { | 120 | { |
120 | if (UUID.Zero == item.Folder) | 121 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) |
121 | { | 122 | { |
122 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 123 | int userlevel = 0; |
123 | if (f != null) | 124 | if (Permissions.IsGod(item.Owner)) |
124 | { | 125 | { |
125 | // m_log.DebugFormat( | 126 | userlevel = 1; |
126 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | 127 | } |
127 | // f.Name, (AssetType)f.Type, item.Name); | 128 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); |
129 | |||
130 | return true; | ||
131 | } | ||
132 | |||
133 | // OK so either the viewer didn't send a folderID or AddItem failed | ||
134 | UUID originalFolder = item.Folder; | ||
135 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | ||
136 | if (f != null) | ||
137 | { | ||
138 | m_log.DebugFormat( | ||
139 | "[AGENT INVENTORY]: Found folder {0} type {1} for item {2}", | ||
140 | f.Name, (AssetType)f.Type, item.Name); | ||
128 | 141 | ||
142 | item.Folder = f.ID; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | f = InventoryService.GetRootFolder(item.Owner); | ||
147 | if (f != null) | ||
148 | { | ||
129 | item.Folder = f.ID; | 149 | item.Folder = f.ID; |
130 | } | 150 | } |
131 | else | 151 | else |
132 | { | 152 | { |
133 | f = InventoryService.GetRootFolder(item.Owner); | 153 | m_log.WarnFormat( |
134 | if (f != null) | 154 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", |
135 | { | 155 | item.Owner, item.Name); |
136 | item.Folder = f.ID; | 156 | return false; |
137 | } | ||
138 | else | ||
139 | { | ||
140 | m_log.WarnFormat( | ||
141 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
142 | item.Owner, item.Name); | ||
143 | return false; | ||
144 | } | ||
145 | } | 157 | } |
146 | } | 158 | } |
147 | 159 | ||
@@ -153,7 +165,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
153 | userlevel = 1; | 165 | userlevel = 1; |
154 | } | 166 | } |
155 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); | 167 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); |
156 | 168 | ||
169 | if (originalFolder != UUID.Zero) | ||
170 | { | ||
171 | // Tell the viewer that the item didn't go there | ||
172 | ChangePlacement(item, f); | ||
173 | } | ||
174 | |||
157 | return true; | 175 | return true; |
158 | } | 176 | } |
159 | else | 177 | else |
@@ -165,7 +183,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | return false; | 183 | return false; |
166 | } | 184 | } |
167 | } | 185 | } |
168 | 186 | ||
187 | private void ChangePlacement(InventoryItemBase item, InventoryFolderBase f) | ||
188 | { | ||
189 | ScenePresence sp = GetScenePresence(item.Owner); | ||
190 | if (sp != null) | ||
191 | { | ||
192 | if (sp.ControllingClient is IClientCore) | ||
193 | { | ||
194 | IClientCore core = (IClientCore)sp.ControllingClient; | ||
195 | IClientInventory inv; | ||
196 | |||
197 | if (core.TryGet<IClientInventory>(out inv)) | ||
198 | { | ||
199 | InventoryFolderBase parent = new InventoryFolderBase(f.ParentID, f.Owner); | ||
200 | parent = InventoryService.GetFolder(parent); | ||
201 | inv.SendRemoveInventoryItems(new UUID[] { item.ID }); | ||
202 | inv.SendBulkUpdateInventory(new InventoryFolderBase[0], new InventoryItemBase[] { item }); | ||
203 | string message = "The item was placed in folder " + f.Name; | ||
204 | if (parent != null) | ||
205 | message += " under " + parent.Name; | ||
206 | sp.ControllingClient.SendAgentAlertMessage(message, false); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
169 | /// <summary> | 212 | /// <summary> |
170 | /// Add the given inventory item to a user's inventory. | 213 | /// Add the given inventory item to a user's inventory. |
171 | /// </summary> | 214 | /// </summary> |