From 6cdbc879d51f04b1dbe63b3eb76dd1f46fec1d7b Mon Sep 17 00:00:00 2001 From: ziree Date: Fri, 9 May 2014 14:03:37 +0200 Subject: [PATCH] Do not allow no copy items to be restored to last position. FIRE-13672 --- indra/newview/app_settings/settings.xml | 13 ++++++++ indra/newview/llagent.cpp | 32 +++++++++++++++++++ indra/newview/llinventorybridge.cpp | 27 ++++++++++++++++ .../skins/default/xui/en/notifications.xml | 9 ++++++ 4 files changed, 81 insertions(+) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c821d6dcc6..3cd4d01e74 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -22039,6 +22039,19 @@ Change of this parameter will affect the layout of buttons in notification toast Value 1 + + AllowNoCopyRezRestoreToWorld + + Comment + Allow Restore to Last Position for no-copy objects on Second Life grids. This can lead to content loss, and is only meant to be used for testing a potential server side fix. + Persist + 1 + Type + Boolean + Value + 0 + + diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 27dd6334d0..0f1786b796 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -4013,6 +4013,38 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **) { //This fires if we're trying to restore an item to world using the correct group. bool remove_from_inventory = false; + + // Do not allow "Restore To Last Position" for no-copy items +#ifdef OPENSIM + if(LLGridManager::instance().isInSecondLife()) + { +#endif + // protect from restoring to last position when the item is no-copy to prevent + // inventory loss + if(!gAgent.restoreToWorldItem->getPermissions().allowCopyBy(gAgent.getID())) + { + if(!gSavedSettings.getBOOL("AllowNoCopyRezRestoreToWorld")) + { + // for some reason, we still came this far, even though we should not have + // allowed RezRestoreToWorld on a no copy item on Second Life grids, so + // log this message and stop proceeding. This will result in the user wearing + // the land group, but hopefully this problem will not come up ever. + LL_WARNS("Avatar") << "Tried RezRestoreToWorld on a no-copy item! Attempt blocked." << LL_ENDL; + + // copied from the end of this function to here, to avoid indention mess + gAgent.restoreToWorld = false; + update_group_floaters(active_id); + // Fire event for group title overview + gAgent.fireEvent(new LLOldEvents::LLEvent(&gAgent, "update grouptitle list"), ""); + + return; + } + } +#ifdef OPENSIM + } +#endif + // + msg->newMessage("RezRestoreToWorld"); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a0ea6d7f8d..c1bcac324b 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -88,6 +88,12 @@ #include "llparcel.h" #include "llviewerparcelmgr.h" +// Do not allow "Restore To Last Postiion" for no-copy items +#ifdef OPENSIM +#include "fsgridhandler.h" +#endif +// + void copy_slurl_to_clipboard_callback_inv(const std::string& slurl); // Marketplace outbox current disabled @@ -1629,6 +1635,27 @@ void LLItemBridge::restoreToWorld() LLViewerInventoryItem* itemp = static_cast(getItem()); if (itemp) { + // Do not allow "Restore To Last Position" for no-copy items +#ifdef OPENSIM + if(LLGridManager::instance().isInSecondLife()) + { +#endif + // do not restore to last position when the item is no-copy to prevent + // inventory loss + if(!itemp->getPermissions().allowCopyBy(gAgent.getID())) + { + // debug guard for future testing of a server side fix + if(!gSavedSettings.getBOOL("AllowNoCopyRezRestoreToWorld")) + { + LLNotificationsUtil::add("CantRestoreToWorldNoCopy"); + return; + } + } +#ifdef OPENSIM + } +#endif + // + LLMessageSystem* msg = gMessageSystem; if (gSavedSettings.getBOOL("RezUnderLandGroup")) diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 317edb88a8..58e27292d2 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11835,4 +11835,13 @@ Enter a domain name to be added to the [LIST]: + + +Restore to Last Position is not allowed for no copy items to prevent possible content loss. + + +