summaryrefslogtreecommitdiff
path: root/indra/newview/llagent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r--indra/newview/llagent.cpp103
1 files changed, 57 insertions, 46 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index c4336758ac..f7b48d25f2 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -56,6 +56,7 @@
#include "llgroupmgr.h"
#include "llhudmanager.h"
#include "lljoystickbutton.h"
+#include "lllandmarkactions.h"
#include "llmorphview.h"
#include "llmoveview.h"
#include "llnavigationbar.h" // to show/hide navigation bar when changing mouse look state
@@ -385,6 +386,10 @@ LLAgent::LLAgent() :
mbRunning(false),
mbTeleportKeepsLookAt(false),
+ mAllowedToStand(true),
+ mAllowedToSit(true),
+ mSitObjectID(LLUUID::null),
+
mAgentAccess(new LLAgentAccess(gSavedSettings)),
mGodLevelChangeSignal(),
mCanEditParcel(false),
@@ -425,8 +430,6 @@ LLAgent::LLAgent() :
mIsDoNotDisturb(false),
mControlFlags(0x00000000),
- mbFlagsDirty(false),
- mbFlagsNeedReset(false),
mAutoPilot(false),
mAutoPilotFlyOnStop(false),
@@ -922,8 +925,6 @@ void LLAgent::setFlying(bool fly, bool fail_sound)
// Update Movement Controls according to Fly mode
LLFloaterMove::setFlyingMode(fly);
-
- mbFlagsDirty = true;
}
@@ -972,7 +973,11 @@ bool LLAgent::isSitting()
void LLAgent::standUp()
{
- setControlFlags(AGENT_CONTROL_STAND_UP);
+ if (mAllowedToStand)
+ {
+ setControlFlags(AGENT_CONTROL_STAND_UP);
+ mSitObjectID = LLUUID::null;
+ }
}
void LLAgent::changeParcels()
@@ -1054,7 +1059,6 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
{
regionp->setCapabilitiesReceivedCallback(LLAgent::capabilityReceivedCallback);
}
-
}
else
{
@@ -1347,7 +1351,7 @@ LLVector3d LLAgent::getPosGlobalFromAgent(const LLVector3 &pos_agent) const
void LLAgent::sitDown()
{
- setControlFlags(AGENT_CONTROL_SIT_ON_GROUND);
+ if (mAllowedToSit) setControlFlags(AGENT_CONTROL_SIT_ON_GROUND);
}
@@ -1542,7 +1546,6 @@ U32 LLAgent::getControlFlags()
void LLAgent::setControlFlags(U32 mask)
{
mControlFlags |= mask;
- mbFlagsDirty = true;
}
@@ -1551,28 +1554,7 @@ void LLAgent::setControlFlags(U32 mask)
//-----------------------------------------------------------------------------
void LLAgent::clearControlFlags(U32 mask)
{
- U32 old_flags = mControlFlags;
mControlFlags &= ~mask;
- if (old_flags != mControlFlags)
- {
- mbFlagsDirty = true;
- }
-}
-
-//-----------------------------------------------------------------------------
-// controlFlagsDirty()
-//-----------------------------------------------------------------------------
-bool LLAgent::controlFlagsDirty() const
-{
- return mbFlagsDirty;
-}
-
-//-----------------------------------------------------------------------------
-// enableControlFlagReset()
-//-----------------------------------------------------------------------------
-void LLAgent::enableControlFlagReset()
-{
- mbFlagsNeedReset = true;
}
//-----------------------------------------------------------------------------
@@ -1580,14 +1562,9 @@ void LLAgent::enableControlFlagReset()
//-----------------------------------------------------------------------------
void LLAgent::resetControlFlags()
{
- if (mbFlagsNeedReset)
- {
- mbFlagsNeedReset = false;
- mbFlagsDirty = false;
- // reset all of the ephemeral flags
- // some flags are managed elsewhere
- mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK;
- }
+ // reset all of the ephemeral flags
+ // some flags are managed elsewhere
+ mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK;
}
//-----------------------------------------------------------------------------
@@ -2071,11 +2048,19 @@ void LLAgent::propagate(const F32 dt)
}
// handle rotation based on keyboard levels
- const F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second
- yaw(YAW_RATE * gAgentCamera.getYawKey() * dt);
+ constexpr F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second
+ F32 angle = YAW_RATE * gAgentCamera.getYawKey() * dt;
+ if (fabs(angle) > 0.0f)
+ {
+ yaw(angle);
+ }
- const F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second
- pitch(PITCH_RATE * gAgentCamera.getPitchKey() * dt);
+ constexpr F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second
+ angle = PITCH_RATE * gAgentCamera.getPitchKey() * dt;
+ if (fabs(angle) > 0.0f)
+ {
+ pitch(angle);
+ }
// handle auto-land behavior
if (isAgentAvatarValid())
@@ -2525,7 +2510,10 @@ void LLAgent::endAnimationUpdateUI()
gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
}
- gFloaterTools->dirty();
+ if (gFloaterTools)
+ {
+ gFloaterTools->dirty();
+ }
// Don't let this be called more than once if the camera
// mode hasn't changed. --JC
@@ -4341,8 +4329,22 @@ void LLAgent::teleportViaLandmark(const LLUUID& landmark_asset_id)
void LLAgent::doTeleportViaLandmark(const LLUUID& landmark_asset_id)
{
- LLViewerRegion *regionp = getRegion();
- if(regionp && teleportCore())
+ LLViewerRegion* regionp = getRegion();
+ if (!regionp)
+ {
+ LL_WARNS("Teleport") << "called when agent region is null" << LL_ENDL;
+ return;
+ }
+
+ bool is_local(false);
+ if (LLLandmark* landmark = gLandmarkList.getAsset(landmark_asset_id, NULL))
+ {
+ LLVector3d pos_global;
+ landmark->getGlobalPos(pos_global);
+ is_local = (regionp->getHandle() == to_region_handle_global((F32)pos_global.mdV[VX], (F32)pos_global.mdV[VY]));
+ }
+
+ if(regionp && teleportCore(is_local))
{
LL_INFOS("Teleport") << "Sending TeleportLandmarkRequest. Current region handle " << regionp->getHandle()
<< " region id " << regionp->getRegionID()
@@ -4903,10 +4905,19 @@ void LLAgent::parseTeleportMessages(const std::string& xml_filename)
LLXMLNodePtr root;
bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
- if (!success || !root || !root->hasName( "teleport_messages" ))
+ if (!success)
{
+ LLError::LLUserWarningMsg::showMissingFiles();
LL_ERRS() << "Problem reading teleport string XML file: "
- << xml_filename << LL_ENDL;
+ << xml_filename << LL_ENDL;
+ return;
+ }
+
+ if (!root || !root->hasName("teleport_messages"))
+ {
+ LLError::LLUserWarningMsg::showMissingFiles();
+ LL_ERRS() << "Invalid teleport string XML file: "
+ << xml_filename << LL_ENDL;
return;
}