diff options
author | Justin Clarke Casey | 2008-01-09 15:46:45 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-01-09 15:46:45 +0000 |
commit | 796ae57bea5e7004ac8d41bee2d496d645db81ce (patch) | |
tree | cf40811cc9b7ae91e679d639785bd6ab4fd422d0 /OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |
parent | * removed another superfluous debug message (diff) | |
download | opensim-SC-796ae57bea5e7004ac8d41bee2d496d645db81ce.zip opensim-SC-796ae57bea5e7004ac8d41bee2d496d645db81ce.tar.gz opensim-SC-796ae57bea5e7004ac8d41bee2d496d645db81ce.tar.bz2 opensim-SC-796ae57bea5e7004ac8d41bee2d496d645db81ce.tar.xz |
Prim inventory script saving phase 2.
* It is now possible to edit and save scripts directly from prim inventories
* On saving, the script will be restarted in the region
* Doesn't appear that it's yet possible to drag inventory contents back to agent inventory. Not quite sure why this is yet - the perms all look very permissive.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 82 |
1 files changed, 52 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 1a05bd9..db3da48 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -58,7 +58,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
58 | /// in which the item is to be placed.</param> | 58 | /// in which the item is to be placed.</param> |
59 | public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) | 59 | public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) |
60 | { | 60 | { |
61 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 61 | CachedUserInfo userInfo |
62 | = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | ||
63 | |||
62 | if (userInfo != null) | 64 | if (userInfo != null) |
63 | { | 65 | { |
64 | userInfo.AddItem(remoteClient.AgentId, item); | 66 | userInfo.AddItem(remoteClient.AgentId, item); |
@@ -157,28 +159,47 @@ namespace OpenSim.Region.Environment.Scenes | |||
157 | /// <param name="itemID"></param> | 159 | /// <param name="itemID"></param> |
158 | /// <param name="primID">The prim which contains the item to update</param> | 160 | /// <param name="primID">The prim which contains the item to update</param> |
159 | /// <param name="isScriptRunning">Indicates whether the script to update is currently running</param> | 161 | /// <param name="isScriptRunning">Indicates whether the script to update is currently running</param> |
160 | /// <param name="data"></param> | 162 | /// <param name="data"></param> |
161 | /// <returns>Asset LLUID created</returns> | ||
162 | public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, | 163 | public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, |
163 | LLUUID primId, bool isScriptRunning, byte[] data) | 164 | LLUUID primId, bool isScriptRunning, byte[] data) |
164 | { | 165 | { |
165 | // TODO Not currently doing anything with the isScriptRunning bool | 166 | // Retrieve group |
167 | SceneObjectPart part = GetSceneObjectPart(primId); | ||
168 | SceneObjectGroup group = part.ParentGroup; | ||
169 | if (null == group) | ||
170 | { | ||
171 | MainLog.Instance.Error( | ||
172 | "PRIMINVENTORY", | ||
173 | "Prim inventory update requested for item ID {0} in prim ID {1} but this prim does not exist", | ||
174 | itemId, primId); | ||
166 | 175 | ||
167 | MainLog.Instance.Verbose( | 176 | return; |
168 | "PRIMINVENTORY", | 177 | } |
169 | "Prim inventory script save functionality not yet implemented." | 178 | |
170 | + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", | ||
171 | remoteClient, itemId, primId, isScriptRunning); | ||
172 | |||
173 | // TODO | ||
174 | // Retrieve client LLUID | ||
175 | // Retrieve sog containing primID | ||
176 | // Retrieve item | 179 | // Retrieve item |
177 | // Create new asset and add to cache | 180 | TaskInventoryItem item = group.GetInventoryItem(part.LocalID, itemId); |
181 | if (null == item) | ||
182 | { | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | // Create new asset | ||
187 | // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this | ||
188 | AssetBase asset = | ||
189 | CreateAsset(item.name, item.desc, 10, 10, data); | ||
190 | AssetCache.AddAsset(asset); | ||
191 | |||
178 | // Update item with new asset | 192 | // Update item with new asset |
179 | // Trigger SOG update (see RezScript) | 193 | item.asset_id = asset.FullID; |
180 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) | 194 | group.UpdateInventoryItem(item); |
181 | // return new asset id | 195 | group.GetProperites(remoteClient); |
196 | |||
197 | // Trigger rerunning of script (use TriggerRezScript event, see RezScript) | ||
198 | if (isScriptRunning) | ||
199 | { | ||
200 | group.StopScript(part.LocalID, item.item_id); | ||
201 | group.StartScript(part.LocalID, item.item_id); | ||
202 | } | ||
182 | } | 203 | } |
183 | 204 | ||
184 | /// <summary> | 205 | /// <summary> |
@@ -268,14 +289,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
268 | } | 289 | } |
269 | else | 290 | else |
270 | { | 291 | { |
271 | MainLog.Instance.Warn( | 292 | MainLog.Instance.Error( |
272 | "AGENTINVENTORY", | 293 | "AGENTINVENTORY", |
273 | "Item ID " + itemID + " not found for an inventory item update."); | 294 | "Item ID " + itemID + " not found for an inventory item update."); |
274 | } | 295 | } |
275 | } | 296 | } |
276 | else | 297 | else |
277 | { | 298 | { |
278 | MainLog.Instance.Warn( | 299 | MainLog.Instance.Error( |
279 | "AGENTINVENTORY", | 300 | "AGENTINVENTORY", |
280 | "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); | 301 | "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); |
281 | } | 302 | } |
@@ -290,7 +311,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
290 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); | 311 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); |
291 | if (userInfo == null) | 312 | if (userInfo == null) |
292 | { | 313 | { |
293 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find user " + oldAgentID.ToString()); | 314 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find user " + oldAgentID.ToString()); |
294 | return; | 315 | return; |
295 | } | 316 | } |
296 | 317 | ||
@@ -299,13 +320,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
299 | item = userInfo.RootFolder.HasItem(oldItemID); | 320 | item = userInfo.RootFolder.HasItem(oldItemID); |
300 | if (item == null) | 321 | if (item == null) |
301 | { | 322 | { |
302 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + oldItemID.ToString()); | 323 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find item " + oldItemID.ToString()); |
303 | return; | 324 | return; |
304 | } | 325 | } |
305 | } | 326 | } |
306 | else | 327 | else |
307 | { | 328 | { |
308 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + oldItemID.ToString()); | 329 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find item " + oldItemID.ToString()); |
309 | return; | 330 | return; |
310 | } | 331 | } |
311 | } | 332 | } |
@@ -346,7 +367,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
346 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 367 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); |
347 | if (userInfo == null) | 368 | if (userInfo == null) |
348 | { | 369 | { |
349 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find user " + remoteClient.AgentId.ToString()); | 370 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find user " + remoteClient.AgentId.ToString()); |
350 | return; | 371 | return; |
351 | } | 372 | } |
352 | 373 | ||
@@ -367,13 +388,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
367 | } | 388 | } |
368 | else | 389 | else |
369 | { | 390 | { |
370 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString()); | 391 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find item " + itemID.ToString()); |
371 | return; | 392 | return; |
372 | } | 393 | } |
373 | } | 394 | } |
374 | else | 395 | else |
375 | { | 396 | { |
376 | MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); | 397 | MainLog.Instance.Error("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); |
377 | return; | 398 | return; |
378 | } | 399 | } |
379 | } | 400 | } |
@@ -476,7 +497,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
476 | } | 497 | } |
477 | else | 498 | else |
478 | { | 499 | { |
479 | MainLog.Instance.Warn( | 500 | MainLog.Instance.Error( |
480 | "PRIMINVENTORY", "Inventory requested of prim {0} which doesn't exist", primLocalID); | 501 | "PRIMINVENTORY", "Inventory requested of prim {0} which doesn't exist", primLocalID); |
481 | } | 502 | } |
482 | } | 503 | } |
@@ -484,7 +505,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
484 | /// <summary> | 505 | /// <summary> |
485 | /// Remove an item from a prim (task) inventory | 506 | /// Remove an item from a prim (task) inventory |
486 | /// </summary> | 507 | /// </summary> |
487 | /// <param name="remoteClient"></param> | 508 | /// <param name="remoteClient">Unused at the moment but retained since the avatar ID might |
509 | /// be necessary for a permissions check at some stage.</param> | ||
488 | /// <param name="itemID"></param> | 510 | /// <param name="itemID"></param> |
489 | /// <param name="localID"></param> | 511 | /// <param name="localID"></param> |
490 | public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) | 512 | public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) |
@@ -492,7 +514,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
492 | SceneObjectGroup group = GetGroupByPrim(localID); | 514 | SceneObjectGroup group = GetGroupByPrim(localID); |
493 | if (group != null) | 515 | if (group != null) |
494 | { | 516 | { |
495 | int type = group.RemoveInventoryItem(remoteClient, localID, itemID); | 517 | int type = group.RemoveInventoryItem(localID, itemID); |
496 | group.GetProperites(remoteClient); | 518 | group.GetProperites(remoteClient); |
497 | if (type == 10) | 519 | if (type == 10) |
498 | { | 520 | { |
@@ -501,7 +523,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
501 | } | 523 | } |
502 | else | 524 | else |
503 | { | 525 | { |
504 | MainLog.Instance.Warn( | 526 | MainLog.Instance.Error( |
505 | "PRIMINVENTORY", | 527 | "PRIMINVENTORY", |
506 | "Removal of item {0} requested of prim {1} but this prim does not exist", | 528 | "Removal of item {0} requested of prim {1} but this prim does not exist", |
507 | itemID, | 529 | itemID, |
@@ -752,4 +774,4 @@ namespace OpenSim.Region.Environment.Scenes | |||
752 | rootPart.ScheduleFullUpdate(); | 774 | rootPart.ScheduleFullUpdate(); |
753 | } | 775 | } |
754 | } | 776 | } |
755 | } \ No newline at end of file | 777 | } |