summaryrefslogtreecommitdiff
path: root/indra/newview/llpathfindinglinkset.cpp
diff options
context:
space:
mode:
authorTodd Stinson <stinson@lindenlab.com>2012-05-30 18:47:12 -0700
committerTodd Stinson <stinson@lindenlab.com>2012-05-30 18:47:12 -0700
commit3c2be426e5e905076d00b9492c0e66c8b31caf19 (patch)
tree08d6c5592f0cf0e5b772812e182fdd71a31893fa /indra/newview/llpathfindinglinkset.cpp
parent5d13d78c13a28b92c339a52403e76eb5a50b7b6b (diff)
First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated.
Diffstat (limited to 'indra/newview/llpathfindinglinkset.cpp')
-rw-r--r--indra/newview/llpathfindinglinkset.cpp168
1 files changed, 53 insertions, 115 deletions
diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp
index e2ece8794f..dca5b6c93d 100644
--- a/indra/newview/llpathfindinglinkset.cpp
+++ b/indra/newview/llpathfindinglinkset.cpp
@@ -29,15 +29,9 @@
#include "llpathfindinglinkset.h"
-#include "v3math.h"
-#include "llavatarname.h"
-#include "llavatarnamecache.h"
+#include "llpathfindingobject.h"
#include "llsd.h"
-#include "lluuid.h"
-#define LINKSET_NAME_FIELD "name"
-#define LINKSET_DESCRIPTION_FIELD "description"
-#define LINKSET_OWNER_FIELD "owner"
#define LINKSET_LAND_IMPACT_FIELD "landimpact"
#define LINKSET_MODIFIABLE_FIELD "modifiable"
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
@@ -51,7 +45,6 @@
#define LINKSET_WALKABILITY_B_FIELD "B"
#define LINKSET_WALKABILITY_C_FIELD "C"
#define LINKSET_WALKABILITY_D_FIELD "D"
-#define LINKSET_POSITION_FIELD "position"
#define LINKSET_CATEGORY_VALUE_INCLUDE 0
#define LINKSET_CATEGORY_VALUE_EXCLUDE 1
@@ -64,15 +57,10 @@
const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0);
const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100);
-LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem)
- : mUUID(),
+LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainData)
+ : LLPathfindingObject(),
mIsTerrain(true),
- mName(),
- mDescription(),
- mOwnerUUID(),
- mOwnerName(),
mLandImpact(0U),
- mLocation(LLVector3::zero),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(true),
#endif // MISSING_MODIFIABLE_FIELD_WAR
@@ -84,18 +72,13 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem)
mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE),
mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE)
{
- parsePathfindingData(pTerrainLinksetItem);
+ parsePathfindingData(pTerrainData);
}
-LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem)
- : mUUID(pUUID),
+LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetData)
+ : LLPathfindingObject(pUUID, pLinksetData),
mIsTerrain(false),
- mName(),
- mDescription(),
- mOwnerUUID(),
- mOwnerName(),
mLandImpact(0U),
- mLocation(LLVector3::zero),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(false),
#endif // MISSING_MODIFIABLE_FIELD_WAR
@@ -107,18 +90,14 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD&
mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE),
mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE)
{
- parseObjectData(pLinksetItem);
- parsePathfindingData(pLinksetItem);
+ parseLinksetData(pLinksetData);
+ parsePathfindingData(pLinksetData);
}
LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther)
- : mUUID(pOther.mUUID),
- mName(pOther.mName),
- mDescription(pOther.mDescription),
- mOwnerUUID(pOther.mOwnerUUID),
- mOwnerName(pOther.mOwnerName),
+ : LLPathfindingObject(pOther),
+ mIsTerrain(pOther.mIsTerrain),
mLandImpact(pOther.mLandImpact),
- mLocation(pOther.mLocation),
#ifdef MISSING_MODIFIABLE_FIELD_WAR
mHasModifiable(pOther.mHasModifiable),
mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE),
@@ -140,13 +119,10 @@ LLPathfindingLinkset::~LLPathfindingLinkset()
LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkset& pOther)
{
- mUUID = pOther.mUUID;
- mName = pOther.mName;
- mDescription = pOther.mDescription;
- mOwnerUUID = pOther.mOwnerUUID;
- mOwnerName = pOther.mOwnerName;
+ dynamic_cast<LLPathfindingObject &>(*this) = pOther;
+
+ mIsTerrain = pOther.mIsTerrain;
mLandImpact = pOther.mLandImpact;
- mLocation = pOther.mLocation;
#ifdef MISSING_MODIFIABLE_FIELD_WAR
if (pOther.mHasModifiable)
{
@@ -166,18 +142,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse
return *this;
}
-std::string LLPathfindingLinkset::getOwnerName() const
-{
- std::string ownerName;
-
- if (hasOwnerName())
- {
- ownerName = mOwnerName.getCompleteName();
- }
-
- return ownerName;
-}
-
BOOL LLPathfindingLinkset::isPhantom() const
{
return isPhantom(getLinksetUse());
@@ -243,111 +207,85 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA,
return itemData;
}
-void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem)
+void LLPathfindingLinkset::parseLinksetData(const LLSD &pLinksetData)
{
- llassert(pLinksetItem.has(LINKSET_NAME_FIELD));
- llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString());
- mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString();
-
- llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD));
- llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString());
- mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString();
-
-#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
- llassert(pLinksetItem.has(LINKSET_OWNER_FIELD));
- llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID());
- mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID();
- LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
-#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
- if (pLinksetItem.has(LINKSET_OWNER_FIELD))
- {
- llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID());
- mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID();
- LLAvatarNameCache::get(mOwnerUUID, &mOwnerName);
- }
-#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE
-
- llassert(pLinksetItem.has(LINKSET_LAND_IMPACT_FIELD));
- llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).isInteger());
- llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0);
- mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger();
+ llassert(pLinksetData.has(LINKSET_LAND_IMPACT_FIELD));
+ llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).isInteger());
+ llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0);
+ mLandImpact = pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger();
#ifdef MISSING_MODIFIABLE_FIELD_WAR
- mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD);
+ mHasModifiable = pLinksetData.has(LINKSET_MODIFIABLE_FIELD);
if (mHasModifiable)
{
- llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
- mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
+ llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
+ mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
}
#else // MISSING_MODIFIABLE_FIELD_WAR
- llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD));
- llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
- mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
+ llassert(pLinksetData.has(LINKSET_MODIFIABLE_FIELD));
+ llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean());
+ mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean();
#endif // MISSING_MODIFIABLE_FIELD_WAR
-
- llassert(pLinksetItem.has(LINKSET_POSITION_FIELD));
- llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray());
- mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD));
}
-void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem)
+void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData)
{
bool isPhantom = false;
- if (pLinksetItem.has(LINKSET_PHANTOM_FIELD))
+ if (pLinksetData.has(LINKSET_PHANTOM_FIELD))
{
- llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean());
- isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean();
+ llassert(pLinksetData.get(LINKSET_PHANTOM_FIELD).isBoolean());
+ isPhantom = pLinksetData.get(LINKSET_PHANTOM_FIELD).asBoolean();
}
#ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
- if (pLinksetItem.has(LINKSET_CATEGORY_FIELD))
+ if (pLinksetData.has(LINKSET_CATEGORY_FIELD))
{
- mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD)));
+ mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD)));
}
else
{
- llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD));
- llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean());
- bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean();
+ llassert(pLinksetData.has(DEPRECATED_LINKSET_PERMANENT_FIELD));
+ llassert(pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean());
+ bool isPermanent = pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean();
- llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD));
- llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean());
- bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean();
+ llassert(pLinksetData.has(DEPRECATED_LINKSET_WALKABLE_FIELD));
+ llassert(pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean());
+ bool isWalkable = pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean();
mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable);
}
#else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
- llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD));
- mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD)));
+ llassert(pLinksetData.has(LINKSET_CATEGORY_FIELD));
+ mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD)));
#endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS
- if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME))
+ if (pLinksetData.has(LINKSET_CAN_BE_VOLUME))
{
- llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean());
- mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean();
+ llassert(pLinksetData.get(LINKSET_CAN_BE_VOLUME).isBoolean());
+ mCanBeVolume = pLinksetData.get(LINKSET_CAN_BE_VOLUME).asBoolean();
}
- llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD));
- llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger());
- mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger();
+ llassert(pLinksetData.has(LINKSET_WALKABILITY_A_FIELD));
+ llassert(pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).isInteger());
+ mWalkabilityCoefficientA = pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).asInteger();
llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE);
- llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD));
- llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger());
- mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger();
+ llassert(pLinksetData.has(LINKSET_WALKABILITY_B_FIELD));
+ llassert(pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).isInteger());
+ mWalkabilityCoefficientB = pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).asInteger();
llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE);
- llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD));
- llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger());
- mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger();
+ llassert(pLinksetData.has(LINKSET_WALKABILITY_C_FIELD));
+ llassert(pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).isInteger());
+ mWalkabilityCoefficientC = pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).asInteger();
llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE);
- llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD));
- llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger());
- mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger();
+ llassert(pLinksetData.has(LINKSET_WALKABILITY_D_FIELD));
+ llassert(pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).isInteger());
+ mWalkabilityCoefficientD = pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).asInteger();
llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE);
llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE);
}