From c80812fb9fc2141902e08b76f18a140b3896a86a Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 22 May 2011 11:34:34 +0200
Subject: [PATCH] - internal : header dependency cleanup for rlvcommon.h and
 rlvhandler.h

--HG--
branch : RLVa
---
 indra/newview/llagent.cpp                |  3 +-
 indra/newview/llagentlistener.cpp        |  3 +-
 indra/newview/llagentwearables.cpp       |  3 +-
 indra/newview/llappearancemgr.cpp        |  4 +-
 indra/newview/llattachmentsmgr.cpp       |  3 +-
 indra/newview/llfloaterinspect.cpp       |  3 +-
 indra/newview/llinventorybridge.cpp      |  3 +-
 indra/newview/llinventoryfunctions.cpp   |  3 +-
 indra/newview/llinventorymodel.cpp       |  3 +-
 indra/newview/llpanelcontents.cpp        |  3 +-
 indra/newview/llpanelobject.cpp          |  3 +-
 indra/newview/llpanelobjectinventory.cpp |  3 +-
 indra/newview/llpreviewscript.cpp        |  3 +-
 indra/newview/llselectmgr.cpp            |  2 +-
 indra/newview/lltooldraganddrop.cpp      |  3 +-
 indra/newview/llviewerdisplay.cpp        |  3 +-
 indra/newview/llviewermenu.cpp           |  4 +-
 indra/newview/llviewerobject.cpp         |  3 +-
 indra/newview/llvoavatarself.cpp         |  3 +-
 indra/newview/llvovolume.cpp             |  3 +-
 indra/newview/llwearableitemslist.cpp    |  3 +-
 indra/newview/pipeline.cpp               |  3 +-
 indra/newview/rlvcommon.cpp              | 39 ++++++++++++
 indra/newview/rlvcommon.h                | 41 ++++++++++---
 indra/newview/rlvextensions.cpp          |  6 +-
 indra/newview/rlvhandler.cpp             | 77 ++++++++++++++++++++++++
 indra/newview/rlvhandler.h               | 77 ------------------------
 indra/newview/rlvhelper.cpp              | 26 --------
 indra/newview/rlvhelper.h                | 18 +-----
 indra/newview/rlvlocks.cpp               |  5 +-
 indra/newview/rlvlocks.h                 |  9 ---
 indra/newview/rlvui.cpp                  |  2 +
 32 files changed, 201 insertions(+), 166 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 29c1030e60..0b9ee71458 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -77,8 +77,9 @@
 #include "llwindow.h"
 #include "llworld.h"
 #include "llworldmap.h"
-// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvhelper.h"
 // [/RLVa:KB]
 
 using namespace LLVOAvatarDefines;
diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp
index 66f3853e79..f9bdc6c44a 100644
--- a/indra/newview/llagentlistener.cpp
+++ b/indra/newview/llagentlistener.cpp
@@ -37,8 +37,9 @@
 #include "llviewerobject.h"
 #include "llviewerobjectlist.h"
 #include "llviewerregion.h"
-// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "llvoavatarself.h"
 // [/RLVa:KB]
 
 LLAgentListener::LLAgentListener(LLAgent &agent)
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 94df06ced7..805930baa4 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -49,8 +49,9 @@
 #include "llvoavatarself.h"
 #include "llwearable.h"
 #include "llwearablelist.h"
-// [RLVa:KB] - Checked: RLVa-1.2.0a (2010-03-04)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 #include <boost/scoped_ptr.hpp>
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index b6dbdadfb5..5e9bf72196 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -49,8 +49,10 @@
 #include "llvoavatarself.h"
 #include "llviewerregion.h"
 #include "llwearablelist.h"
-// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0b)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvhelper.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 // RAII thingy to guarantee that a variable gets reset when the Setter
diff --git a/indra/newview/llattachmentsmgr.cpp b/indra/newview/llattachmentsmgr.cpp
index 56490162b1..8a74fd5d87 100644
--- a/indra/newview/llattachmentsmgr.cpp
+++ b/indra/newview/llattachmentsmgr.cpp
@@ -33,8 +33,9 @@
 #include "llviewerinventory.h"
 #include "llviewerregion.h"
 #include "message.h"
-// [RLVa:KB] - Checked: 2010-09-13 (RLVa-1.2.1c)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 LLAttachmentsMgr::LLAttachmentsMgr()
diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp
index dd25e3a52f..2e5efdbeee 100644
--- a/indra/newview/llfloaterinspect.cpp
+++ b/indra/newview/llfloaterinspect.cpp
@@ -40,8 +40,9 @@
 #include "llviewercontrol.h"
 #include "llviewerobject.h"
 #include "lluictrlfactory.h"
-// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "llagent.h"
 // [/RLVa:KB]
 
 //LLFloaterInspect* LLFloaterInspect::sInstance = NULL;
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index eb84b69e15..97061ae024 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -68,8 +68,9 @@
 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llwearablelist.h"
-// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 typedef std::pair<LLUUID, LLUUID> two_uuids_t;
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 18dcc865b7..2af361a422 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -80,8 +80,9 @@
 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llwearablelist.h"
-// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0b) | Added: RLVa-1.3.0b
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 BOOL LLInventoryState::sWearNewClothing = FALSE;
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 430d5a103e..d3fca200af 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -46,8 +46,9 @@
 #include "llviewerregion.h"
 #include "llcallbacklist.h"
 #include "llvoavatarself.h"
-// [RLVa:KB] - Checked: RLVa-1.2.0a (2010-03-05)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 //#define DIFF_INVENTORY_FILES
diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp
index 290d76333a..47425c3f19 100644
--- a/indra/newview/llpanelcontents.cpp
+++ b/indra/newview/llpanelcontents.cpp
@@ -59,8 +59,9 @@
 #include "llviewerregion.h"
 #include "llviewerwindow.h"
 #include "llworld.h"
-// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 //
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 9e1b78656b..6e19c34241 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -68,8 +68,9 @@
 #include "llviewercontrol.h"
 #include "lluictrlfactory.h"
 //#include "llfirstuse.h"
-// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "llvoavatarself.h"
 // [/RLVa:KB]
 
 #include "lldrawpool.h"
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 1fbfea01c1..8dfa2531b0 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -63,8 +63,9 @@
 #include "llviewerregion.h"
 #include "llviewerobjectlist.h"
 #include "llviewermessage.h"
-// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 ///----------------------------------------------------------------------------
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 0d71da82b7..5d1d49a7fc 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -85,8 +85,9 @@
 #include "lltrans.h"
 #include "llviewercontrol.h"
 #include "llappviewer.h"
-// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 const std::string HELLO_LSL =
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9eef7abd70..7f067a8358 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -88,7 +88,7 @@
 #include "llvoavatarself.h"
 #include "llvovolume.h"
 #include "pipeline.h"
-// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
 // [/RLVa:KB]
 
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 60c201c166..79886241a3 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -58,8 +58,9 @@
 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llworld.h"
-// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 // syntactic sugar
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 11f311e9b0..983a8d48ff 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -77,8 +77,9 @@
 #include "llwlparammanager.h"
 #include "llwaterparammanager.h"
 #include "llpostprocess.h"
-// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 extern LLPointer<LLViewerTexture> gStartTexture;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 2957a60da2..ed07348746 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -105,9 +105,9 @@
 #include "lltrans.h"
 #include "lleconomy.h"
 #include "boost/unordered_map.hpp"
-
-// [RLVa:KB] - Checked: 2010-03-09 (RLVa-1.2.0a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 using namespace LLVOAvatarDefines;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index db0df4900c..5b923ff9aa 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -100,8 +100,9 @@
 #include "lltrans.h"
 #include "llsdutil.h"
 #include "llmediaentry.h"
-// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 //#define DEBUG_UPDATE_TYPE
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index b1231bce36..87ab9afcf7 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -56,8 +56,9 @@
 #include "llviewerstats.h"
 #include "llviewerregion.h"
 #include "llappearancemgr.h"
-// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 #if LL_MSVC
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index ab26585647..d4c2125106 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -63,8 +63,9 @@
 #include "llmediadataclient.h"
 #include "llagent.h"
 #include "llviewermediafocus.h"
-// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.0d)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 const S32 MIN_QUIET_FRAMES_COALESCE = 30;
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index 9c68d6e9ca..6ebf5eac5c 100644
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -37,8 +37,9 @@
 #include "lltransutil.h"
 #include "llviewerattachmenu.h"
 #include "llvoavatarself.h"
-// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1a)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 class LLFindOutfitItems : public LLInventoryCollectFunctor
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 9ff0747166..abd2b38491 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -100,8 +100,9 @@
 #include "llspatialpartition.h"
 #include "llmutelist.h"
 #include "lltoolpie.h"
-// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.0d)
+// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
 #include "rlvhandler.h"
+#include "rlvlocks.h"
 // [/RLVa:KB]
 
 #ifdef _DEBUG
diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp
index 204a3f1ff1..8b32eedfef 100644
--- a/indra/newview/rlvcommon.cpp
+++ b/indra/newview/rlvcommon.cpp
@@ -29,6 +29,7 @@
 #include "llworld.h"
 
 #include "rlvcommon.h"
+#include "rlvhelper.h"
 #include "rlvhandler.h"
 #include "rlvlocks.h"
 
@@ -522,6 +523,32 @@ bool rlvMenuEnableIfNot(const LLSD& sdParam)
 // Selection functors
 //
 
+// Checked: 2010-04-11 (RLVa-1.2.0b) | Modified: RLVa-0.2.0g
+bool rlvCanDeleteOrReturn()
+{
+	bool fIsAllowed = true;
+
+	if (gRlvHandler.hasBehaviour(RLV_BHVR_REZ))
+	{
+		// We'll allow if none of the prims are owned by the avie or group owned
+		LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
+		RlvSelectIsOwnedByOrGroupOwned f(gAgent.getID());
+		if ( (handleSel.notNull()) && ((0 == handleSel->getRootObjectCount()) || (NULL != handleSel->getFirstRootNode(&f, FALSE))) )
+			fIsAllowed = false;
+	}
+	
+	if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) )
+	{
+		// We'll allow if the avie isn't sitting on any of the selected objects
+		LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
+		RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
+		if ( (handleSel.notNull()) && (handleSel->getFirstRootNode(&f, TRUE)) )
+			fIsAllowed = false;
+	}
+
+	return fIsAllowed;
+}
+
 // Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-0.2.0f
 bool RlvSelectHasLockedAttach::apply(LLSelectNode* pNode)
 {
@@ -609,6 +636,18 @@ bool rlvPredCanNotRemoveItem(const LLViewerInventoryItem* pItem)
 	return !rlvPredCanRemoveItem(pItem);
 }
 
+// Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
+RlvPredIsEqualOrLinkedItem::RlvPredIsEqualOrLinkedItem(const LLUUID& idItem)
+{
+	m_pItem = gInventory.getItem(idItem);
+}
+
+// Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
+bool RlvPredIsEqualOrLinkedItem::operator()(const LLViewerInventoryItem* pItem) const
+{
+	return (m_pItem) && (pItem) && (m_pItem->getLinkedUUID() == pItem->getLinkedUUID());
+}
+
 // ============================================================================
 // Various public helper functions
 //
diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h
index 5df06803b2..7c735dfa68 100644
--- a/indra/newview/rlvcommon.h
+++ b/indra/newview/rlvcommon.h
@@ -18,21 +18,44 @@
 #define RLV_COMMON_H
 
 #include "llavatarname.h"
-#include "llinventorymodel.h"
 #include "llselectmgr.h"
 #include "llviewercontrol.h"
-#include "llviewerinventory.h"
 
 #include "rlvdefines.h"
 
+#ifdef LL_WINDOWS
+	#pragma warning (push)
+	#pragma warning (disable : 4702) // warning C4702: unreachable code
+#endif
+#include <boost/variant.hpp>
+#ifdef LL_WINDOWS
+	#pragma warning (pop)
+#endif
+
 // ============================================================================
 // Forward declarations
 //
 
+//
+// General viewer source
+//
+class LLInventoryItem;
+class LLViewerInventoryCategory;
+class LLViewerInventoryItem;
+class LLViewerJointAttachment;
+
+//
+// RLVa-specific
+//
 class RlvCommand;
+typedef std::list<RlvCommand> rlv_command_list_t;
+class RlvObject;
+
+struct RlvException;
+typedef boost::variant<std::string, LLUUID, S32, ERlvBehaviour> RlvExceptionOption;
 
-typedef std::vector<LLViewerObject*> llvo_vec_t;
-typedef std::vector<const LLViewerObject*> c_llvo_vec_t;
+class RlvGCTimer;
+class RlvWLSnapshot;
 
 // ============================================================================
 // RlvSettings
@@ -177,6 +200,8 @@ bool rlvMenuEnableIfNot(const LLSD& sdParam);
 // Selection functors
 //
 
+bool rlvCanDeleteOrReturn();
+
 struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor
 {
 	RlvSelectHasLockedAttach() {}
@@ -234,12 +259,8 @@ protected:
 struct RlvPredIsEqualOrLinkedItem
 {
 	RlvPredIsEqualOrLinkedItem(const LLViewerInventoryItem* pItem) : m_pItem(pItem) {}
-	RlvPredIsEqualOrLinkedItem(const LLUUID& idItem) { m_pItem = gInventory.getItem(idItem); }
-
-	bool operator()(const LLViewerInventoryItem* pItem) const
-	{
-		return (m_pItem) && (pItem) && (m_pItem->getLinkedUUID() == pItem->getLinkedUUID());
-	}
+	RlvPredIsEqualOrLinkedItem(const LLUUID& idItem);
+	bool operator()(const LLViewerInventoryItem* pItem) const;
 protected:
 	const LLViewerInventoryItem* m_pItem;
 };
diff --git a/indra/newview/rlvextensions.cpp b/indra/newview/rlvextensions.cpp
index 68fa81f04b..d587c075f0 100644
--- a/indra/newview/rlvextensions.cpp
+++ b/indra/newview/rlvextensions.cpp
@@ -15,15 +15,15 @@
  */
 
 #include "llviewerprecompiledheaders.h"
-//#include "llagent.h"
+#include "llagent.h"
 #include "llagentcamera.h"
 #include "llviewercontrol.h"
-//#include "llviewerwindow.h"
-//#include "llvoavatar.h"
+#include "llvoavatarself.h"
 #include "llwlparammanager.h"
 
 #include "rlvextensions.h"
 #include "rlvhandler.h"
+#include "rlvhelper.h"
 
 // ============================================================================
 
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index c6b04f4823..710b72ef77 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -21,6 +21,7 @@
 #include "llcallbacklist.h"
 #include "llgroupactions.h"
 #include "llhudtext.h"
+#include "llstartup.h"
 #include "llviewermessage.h"
 #include "llviewerobjectlist.h"
 #include "llviewerparcelmgr.h"
@@ -106,6 +107,16 @@ bool RlvHandler::hasBehaviourRoot(const LLUUID& idObjRoot, ERlvBehaviour eBhvr,
 	return false;
 }
 
+// ============================================================================
+// Behaviour exception handling
+//
+
+// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a
+void RlvHandler::addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption)
+{
+	m_Exceptions.insert(std::pair<ERlvBehaviour, RlvException>(eBhvr, RlvException(idObj, eBhvr, varOption)));
+}
+
 // Checked: 2009-10-04 (RLVa-1.0.4c) | Modified: RLVa-1.0.4c
 bool RlvHandler::isException(ERlvBehaviour eBhvr, const RlvExceptionOption& varOption, ERlvExceptionCheck typeCheck) const
 {
@@ -142,6 +153,28 @@ bool RlvHandler::isException(ERlvBehaviour eBhvr, const RlvExceptionOption& varO
 	return false;
 }
 
+// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a
+bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const
+{
+	return (RlvCommand::hasStrictVariant(eBhvr)) 
+		? !((hasBehaviour(RLV_BHVR_PERMISSIVE)) || (isException(RLV_BHVR_PERMISSIVE, eBhvr, RLV_CHECK_PERMISSIVE)))
+		: true;
+}
+
+// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a
+void RlvHandler::removeException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption)
+{
+	for (rlv_exception_map_t::iterator itException = m_Exceptions.lower_bound(eBhvr), 
+			endException = m_Exceptions.upper_bound(eBhvr); itException != endException; ++itException)
+	{
+		if ( (itException->second.idObject == idObj) && (itException->second.varOption == varOption) )
+		{
+			m_Exceptions.erase(itException);
+			break;
+		}
+	}
+}
+
 // ============================================================================
 // Command processing functions
 //
@@ -308,6 +341,17 @@ ERlvCmdRet RlvHandler::processCommand(const RlvCommand& rlvCmd, bool fFromObj)
 	return eRet;
 }
 
+// Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f
+ERlvCmdRet RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj)
+{
+	if (STATE_STARTED != LLStartUp::getStartupState())
+	{
+		m_Retained.push_back(RlvCommand(idObj, strCommand));
+		return RLV_RET_RETAINED;
+	}
+	return processCommand(RlvCommand(idObj, strCommand), fFromObj);
+}
+
 // Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.1.0f
 void RlvHandler::processRetainedCommands(ERlvBehaviour eBhvrFilter /*=RLV_BHVR_UNKNOWN*/, ERlvParamType eTypeFilter /*=RLV_TYPE_UNKNOWN*/)
 {
@@ -583,6 +627,33 @@ void RlvHandler::onTeleportFinished(const LLVector3d& posArrival)
 // String/chat censoring functions
 //
 
+// Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.1.0j
+bool RlvHandler::canSit(LLViewerObject* pObj, const LLVector3& posOffset /*= LLVector3::zero*/) const
+{
+	// The user can sit on the specified object if:
+	//   - not prevented from sitting
+	//   - not prevented from standing up or not currently sitting
+	//   - not standtp restricted or not currently sitting (if the user is sitting and tried to sit elsewhere the tp would just kick in)
+	//   - [regular sit] not @sittp=n or @fartouch=n restricted or if they clicked on a point within 1.5m of the avie's current position
+	//   - [force sit] not @sittp=n restricted by a *different* object than the one that issued the command or the object is within 1.5m
+	return
+		( (pObj) && (LL_PCODE_VOLUME == pObj->getPCode()) ) &&
+		(!hasBehaviour(RLV_BHVR_SIT)) && 
+		( ((!hasBehaviour(RLV_BHVR_UNSIT)) && (!hasBehaviour(RLV_BHVR_STANDTP))) || 
+		  ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting())) ) &&
+		( ((NULL == getCurrentCommand() || (RLV_BHVR_SIT != getCurrentCommand()->getBehaviourType()))
+			? ((!hasBehaviour(RLV_BHVR_SITTP)) && (!hasBehaviour(RLV_BHVR_FARTOUCH)))	// [regular sit]
+			: (!hasBehaviourExcept(RLV_BHVR_SITTP, getCurrentObject()))) ||				// [force sit]
+		  (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < 1.5f * 1.5f) );
+}
+
+// Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a
+bool RlvHandler::canStand() const
+{
+	// NOTE: return FALSE only if we're @unsit=n restricted and the avie is currently sitting on something and TRUE for everything else
+	return (!hasBehaviour(RLV_BHVR_UNSIT)) || ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting()));
+}
+
 // Checked: 2010-04-11 (RLVa-1.3.0h) | Modified: RLVa-1.3.0h
 bool RlvHandler::canTouch(const LLViewerObject* pObj, const LLVector3& posOffset /*=LLVector3::zero*/) const
 {
@@ -686,6 +757,12 @@ void RlvHandler::filterChat(std::string& strUTF8Text, bool fFilterEmote) const
 	}
 }
 
+// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c
+bool RlvHandler::hasException(ERlvBehaviour eBhvr) const
+{
+	return (m_Exceptions.find(eBhvr) != m_Exceptions.end());
+}
+
 // Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a
 bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const
 {
diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h
index 320cdaf9ac..209ad17a58 100644
--- a/indra/newview/rlvhandler.h
+++ b/indra/newview/rlvhandler.h
@@ -18,14 +18,8 @@
 #define RLV_HANDLER_H
 
 #include <stack>
-#include "llagentconstants.h"
-#include "llstartup.h"
-#include "llviewerjointattachment.h"
-#include "llviewerobject.h"
 
 #include "rlvcommon.h"
-#include "rlvhelper.h"
-#include "rlvlocks.h"
 
 // ============================================================================
 
@@ -235,12 +229,6 @@ extern rlv_handler_t gRlvHandler;
 // Inlined member functions
 //
 
-// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a
-inline void RlvHandler::addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption)
-{
-	m_Exceptions.insert(std::pair<ERlvBehaviour, RlvException>(eBhvr, RlvException(idObj, eBhvr, varOption)));
-}
-
 // Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c
 inline bool RlvHandler::canEdit(const LLViewerObject* pObj) const
 {
@@ -285,26 +273,6 @@ inline bool RlvHandler::canShowHoverText(const LLViewerObject *pObj) const
 			   (isException(RLV_BHVR_SHOWHOVERTEXT, pObj->getID(), RLV_CHECK_PERMISSIVE)) ) );
 }
 
-// Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.1.0j
-inline bool RlvHandler::canSit(LLViewerObject* pObj, const LLVector3& posOffset /*= LLVector3::zero*/) const
-{
-	// The user can sit on the specified object if:
-	//   - not prevented from sitting
-	//   - not prevented from standing up or not currently sitting
-	//   - not standtp restricted or not currently sitting (if the user is sitting and tried to sit elsewhere the tp would just kick in)
-	//   - [regular sit] not @sittp=n or @fartouch=n restricted or if they clicked on a point within 1.5m of the avie's current position
-	//   - [force sit] not @sittp=n restricted by a *different* object than the one that issued the command or the object is within 1.5m
-	return
-		( (pObj) && (LL_PCODE_VOLUME == pObj->getPCode()) ) &&
-		(!hasBehaviour(RLV_BHVR_SIT)) && 
-		( ((!hasBehaviour(RLV_BHVR_UNSIT)) && (!hasBehaviour(RLV_BHVR_STANDTP))) || 
-		  ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting())) ) &&
-		( ((NULL == getCurrentCommand() || (RLV_BHVR_SIT != getCurrentCommand()->getBehaviourType()))
-			? ((!hasBehaviour(RLV_BHVR_SITTP)) && (!hasBehaviour(RLV_BHVR_FARTOUCH)))	// [regular sit]
-			: (!hasBehaviourExcept(RLV_BHVR_SITTP, getCurrentObject()))) ||				// [force sit]
-		  (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < 1.5f * 1.5f) );
-}
-
 inline bool RlvHandler::canStartIM(const LLUUID& idRecipient) const
 {
 	// User can start an IM session with "recipient" (could be an agent or a group) if:
@@ -315,13 +283,6 @@ inline bool RlvHandler::canStartIM(const LLUUID& idRecipient) const
 		( (!hasBehaviour(RLV_BHVR_STARTIMTO)) || (!isException(RLV_BHVR_STARTIMTO, idRecipient)) );
 }
 
-// Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a
-inline bool RlvHandler::canStand() const
-{
-	// NOTE: return FALSE only if we're @unsit=n restricted and the avie is currently sitting on something and TRUE for everything else
-	return (!hasBehaviour(RLV_BHVR_UNSIT)) || ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting()));
-}
-
 // Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c
 inline bool RlvHandler::canTeleportViaLure(const LLUUID& idAgent) const
 {
@@ -338,44 +299,6 @@ inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBhvr, const LLUUID& id
 	return hasBehaviourExcept(eBhvr, LLStringUtil::null, idObj);
 }
 
-// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c
-inline bool RlvHandler::hasException(ERlvBehaviour eBhvr) const
-{
-	return (m_Exceptions.find(eBhvr) != m_Exceptions.end());
-}
-
-inline bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const
-{
-	return (RlvCommand::hasStrictVariant(eBhvr)) 
-		? !((hasBehaviour(RLV_BHVR_PERMISSIVE)) || (isException(RLV_BHVR_PERMISSIVE, eBhvr, RLV_CHECK_PERMISSIVE)))
-		: true;
-}
-
-// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a
-inline void RlvHandler::removeException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption)
-{
-	for (rlv_exception_map_t::iterator itException = m_Exceptions.lower_bound(eBhvr), 
-			endException = m_Exceptions.upper_bound(eBhvr); itException != endException; ++itException)
-	{
-		if ( (itException->second.idObject == idObj) && (itException->second.varOption == varOption) )
-		{
-			m_Exceptions.erase(itException);
-			break;
-		}
-	}
-}
-
-// Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f
-inline ERlvCmdRet RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj)
-{
-	if (STATE_STARTED != LLStartUp::getStartupState())
-	{
-		m_Retained.push_back(RlvCommand(idObj, strCommand));
-		return RLV_RET_RETAINED;
-	}
-	return processCommand(RlvCommand(idObj, strCommand), fFromObj);
-}
-
 // ============================================================================
 
 #endif // RLV_HANDLER_H
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index 60a5260674..8382b20618 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -1087,32 +1087,6 @@ BOOL RlvGCTimer::tick()
 // Various helper functions
 //
 
-// Checked: 2010-04-11 (RLVa-1.2.0b) | Modified: RLVa-0.2.0g
-bool rlvCanDeleteOrReturn()
-{
-	bool fIsAllowed = true;
-
-	if (gRlvHandler.hasBehaviour(RLV_BHVR_REZ))
-	{
-		// We'll allow if none of the prims are owned by the avie or group owned
-		LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
-		RlvSelectIsOwnedByOrGroupOwned f(gAgent.getID());
-		if ( (handleSel.notNull()) && ((0 == handleSel->getRootObjectCount()) || (NULL != handleSel->getFirstRootNode(&f, FALSE))) )
-			fIsAllowed = false;
-	}
-	
-	if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) )
-	{
-		// We'll allow if the avie isn't sitting on any of the selected objects
-		LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
-		RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
-		if ( (handleSel.notNull()) && (handleSel->getFirstRootNode(&f, TRUE)) )
-			fIsAllowed = false;
-	}
-
-	return fIsAllowed;
-}
-
 // ============================================================================
 // Attachment group helper functions
 //
diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h
index ee6bea9a8b..45cb50cf68 100644
--- a/indra/newview/rlvhelper.h
+++ b/indra/newview/rlvhelper.h
@@ -18,20 +18,13 @@
 #define RLV_HELPER_H
 
 #include "lleventtimer.h"
+#include "llinventorymodel.h"
+#include "llviewerinventory.h"
 #include "llwlparamset.h"
 
 #include "rlvdefines.h"
 #include "rlvcommon.h"
 
-#ifdef LL_WINDOWS
-	#pragma warning (push)
-	#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif
-#include <boost/variant.hpp>
-#ifdef LL_WINDOWS
-	#pragma warning (pop)
-#endif
-
 // ============================================================================
 // RlvCommand
 //
@@ -88,7 +81,6 @@ protected:
 
 	friend class RlvHandler;
 };
-typedef std::list<RlvCommand> rlv_command_list_t;
 
 // ============================================================================
 // RlvCommandOption (and derived classed)
@@ -358,8 +350,6 @@ protected:
 // RlvException
 //
 
-typedef boost::variant<std::string, LLUUID, S32, ERlvBehaviour> RlvExceptionOption;
-
 struct RlvException
 {
 public:
@@ -376,7 +366,7 @@ private:
 // RlvWLSnapshot
 //
 
-struct RlvWLSnapshot
+class RlvWLSnapshot
 {
 public:
 	static void           restoreSnapshot(const RlvWLSnapshot* pWLSnapshot);
@@ -425,8 +415,6 @@ inline void rlvCallbackTimerOnce(F32 nPeriod, RlvCallbackTimerOnce::nullary_func
 // Various helper functions
 //
 
-bool rlvCanDeleteOrReturn();
-
 ERlvAttachGroupType rlvAttachGroupFromIndex(S32 idxGroup);
 ERlvAttachGroupType rlvAttachGroupFromString(const std::string& strGroup);
 
diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp
index 0ca9105071..b2414d438e 100644
--- a/indra/newview/rlvlocks.cpp
+++ b/indra/newview/rlvlocks.cpp
@@ -511,7 +511,7 @@ void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const LLViewerObject* pA
 	if (!pAttachPt)
 		return;
 
-	c_llvo_vec_t attachObjs;
+	std::vector<const LLViewerObject*> attachObjs;
 	for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
 			itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
 	{
@@ -527,7 +527,7 @@ void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const LLViewerObject* pA
 		gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 		gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
 		
-		for (c_llvo_vec_t::const_iterator itAttachObj = attachObjs.begin(); itAttachObj != attachObjs.end(); ++itAttachObj)
+		for (std::vector<const LLViewerObject*>::const_iterator itAttachObj = attachObjs.begin(); itAttachObj != attachObjs.end(); ++itAttachObj)
 		{
 			const LLViewerObject* pAttachObj = *itAttachObj;
 			gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
@@ -608,7 +608,6 @@ void RlvAttachmentLockWatchdog::onAttach(const LLViewerObject* pAttachObj, const
 				else
 				{
 					// Iterate over all the current attachments and force detach any that shouldn't be there
-					c_llvo_vec_t attachObjs;
 					for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
 							itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
 					{
diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h
index 31cfb0c1fa..c0a5fed89f 100644
--- a/indra/newview/rlvlocks.h
+++ b/indra/newview/rlvlocks.h
@@ -23,15 +23,6 @@
 #include "rlvdefines.h"
 #include "rlvcommon.h"
 
-#ifdef LL_WINDOWS
-	#pragma warning (push)
-	#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif
-#include <boost/variant.hpp>
-#ifdef LL_WINDOWS
-	#pragma warning (pop)
-#endif
-
 // ============================================================================
 // RlvAttachPtLookup class declaration
 //
diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp
index 0c7631e1d0..37b7d3c8be 100644
--- a/indra/newview/rlvui.cpp
+++ b/indra/newview/rlvui.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "llviewerprecompiledheaders.h"
+#include "llagent.h"
 #include "llavatarlist.h"				// Avatar list control used by the "Nearby" tab in the "People" sidebar panel
 #include "llavatarnamecache.h"
 #include "llbottomtray.h"
@@ -40,6 +41,7 @@
 #include "llteleporthistorystorage.h"
 #include "lltoolmgr.h"
 #include "llviewerparcelmgr.h"
+#include "llvoavatar.h"
 #include "roles_constants.h"			// Group "powers"
 
 #include "rlvui.h"
-- 
GitLab