aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llagent.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llagent.cpp')
-rw-r--r--linden/indra/newview/llagent.cpp234
1 files changed, 123 insertions, 111 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp
index b65a1f6..d268397 100644
--- a/linden/indra/newview/llagent.cpp
+++ b/linden/indra/newview/llagent.cpp
@@ -94,6 +94,7 @@
94#include "llsky.h" 94#include "llsky.h"
95#include "llrendersphere.h" 95#include "llrendersphere.h"
96#include "llstatusbar.h" 96#include "llstatusbar.h"
97#include "llstartup.h"
97#include "llimview.h" 98#include "llimview.h"
98#include "lltool.h" 99#include "lltool.h"
99#include "lltoolfocus.h" 100#include "lltoolfocus.h"
@@ -125,14 +126,10 @@
125#include "roles_constants.h" 126#include "roles_constants.h"
126#include "llviewercontrol.h" 127#include "llviewercontrol.h"
127#include "llappviewer.h" 128#include "llappviewer.h"
128#include "llvoiceclient.h" 129#include "llviewerjoystick.h"
129
130// Ventrella
131#include "llfollowcam.h" 130#include "llfollowcam.h"
132// end Ventrella
133 131
134extern LLMenuBarGL* gMenuBarView; 132extern LLMenuBarGL* gMenuBarView;
135extern U8 gLastPickAlpha;
136 133
137//drone wandering constants 134//drone wandering constants
138const F32 MAX_WANDER_TIME = 20.f; // seconds 135const F32 MAX_WANDER_TIME = 20.f; // seconds
@@ -176,7 +173,7 @@ const F32 AVATAR_ZOOM_MIN_Z_FACTOR = 1.15f;
176 173
177const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f; 174const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f;
178 175
179const F32 MAX_CAMERA_SMOOTH_DISTANCE = 20.0f; 176const F32 MAX_CAMERA_SMOOTH_DISTANCE = 50.0f;
180 177
181const F32 HEAD_BUFFER_SIZE = 0.3f; 178const F32 HEAD_BUFFER_SIZE = 0.3f;
182const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f; 179const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f;
@@ -236,8 +233,8 @@ BOOL LLAgent::sDebugDisplayTarget = FALSE;
236 233
237const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; 234const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f;
238 235
239std::map<LLString, LLString> LLAgent::sTeleportErrorMessages; 236std::map<std::string, std::string> LLAgent::sTeleportErrorMessages;
240std::map<LLString, LLString> LLAgent::sTeleportProgressMessages; 237std::map<std::string, std::string> LLAgent::sTeleportProgressMessages;
241 238
242class LLAgentFriendObserver : public LLFriendObserver 239class LLAgentFriendObserver : public LLFriendObserver
243{ 240{
@@ -329,6 +326,8 @@ LLAgent::LLAgent()
329 mCameraZoomFraction(1.f), // deprecated 326 mCameraZoomFraction(1.f), // deprecated
330 mThirdPersonHeadOffset(0.f, 0.f, 1.f), 327 mThirdPersonHeadOffset(0.f, 0.f, 1.f),
331 mSitCameraEnabled(FALSE), 328 mSitCameraEnabled(FALSE),
329 mHUDTargetZoom(1.f),
330 mHUDCurZoom(1.f),
332 mFocusOnAvatar(TRUE), 331 mFocusOnAvatar(TRUE),
333 mFocusGlobal(), 332 mFocusGlobal(),
334 mFocusTargetGlobal(), 333 mFocusTargetGlobal(),
@@ -338,6 +337,7 @@ LLAgent::LLAgent()
338 mTrackFocusObject(TRUE), 337 mTrackFocusObject(TRUE),
339 mCameraSmoothingLastPositionGlobal(), 338 mCameraSmoothingLastPositionGlobal(),
340 mCameraSmoothingLastPositionAgent(), 339 mCameraSmoothingLastPositionAgent(),
340 mCameraSmoothingStop(FALSE),
341 341
342 mFrameAgent(), 342 mFrameAgent(),
343 343
@@ -529,10 +529,7 @@ void LLAgent::resetView(BOOL reset_camera)
529 setFocusOnAvatar(TRUE, ANIMATE); 529 setFocusOnAvatar(TRUE, ANIMATE);
530 } 530 }
531 531
532 if (mAvatarObject.notNull()) 532 mHUDTargetZoom = 1.f;
533 {
534 mAvatarObject->mHUDTargetZoom = 1.f;
535 }
536} 533}
537 534
538// Handle any actions that need to be performed when the main app gains focus 535// Handle any actions that need to be performed when the main app gains focus
@@ -819,13 +816,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
819 llassert(regionp); 816 llassert(regionp);
820 if (mRegionp != regionp) 817 if (mRegionp != regionp)
821 { 818 {
822 // JC - Avoid this, causes out-of-bounds array write deep within 819 // std::string host_name;
823 // Windows. 820 // host_name = regionp->getHost().getHostName();
824 // char host_name[MAX_STRING];
825 // regionp->getHost().getHostName(host_name, MAX_STRING);
826 821
827 char ip[MAX_STRING]; /*Flawfinder: ignore*/ 822 std::string ip = regionp->getHost().getString();
828 regionp->getHost().getString(ip, MAX_STRING);
829 llinfos << "Moving agent into region: " << regionp->getName() 823 llinfos << "Moving agent into region: " << regionp->getName()
830 << " located at " << ip << llendl; 824 << " located at " << ip << llendl;
831 if (mRegionp) 825 if (mRegionp)
@@ -1300,7 +1294,7 @@ LLQuaternion LLAgent::getQuat() const
1300//----------------------------------------------------------------------------- 1294//-----------------------------------------------------------------------------
1301// calcFocusOffset() 1295// calcFocusOffset()
1302//----------------------------------------------------------------------------- 1296//-----------------------------------------------------------------------------
1303LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) 1297LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1304{ 1298{
1305 // calculate offset based on view direction 1299 // calculate offset based on view direction
1306 BOOL is_avatar = object->isAvatar(); 1300 BOOL is_avatar = object->isAvatar();
@@ -1459,10 +1453,10 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1459 1453
1460 obj_rel = lerp(focus_delta, obj_rel, bias); 1454 obj_rel = lerp(focus_delta, obj_rel, bias);
1461 1455
1462 return LLVector3d(obj_rel); 1456 return LLVector3(obj_rel);
1463 } 1457 }
1464 1458
1465 return LLVector3d(focus_delta.mV[VX], focus_delta.mV[VY], focus_delta.mV[VZ]); 1459 return LLVector3(focus_delta.mV[VX], focus_delta.mV[VY], focus_delta.mV[VZ]);
1466} 1460}
1467 1461
1468//----------------------------------------------------------------------------- 1462//-----------------------------------------------------------------------------
@@ -1652,7 +1646,7 @@ F32 LLAgent::getCameraZoomFraction()
1652 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1646 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1653 { 1647 {
1654 // already [0,1] 1648 // already [0,1]
1655 return mAvatarObject->mHUDTargetZoom; 1649 return mHUDTargetZoom;
1656 } 1650 }
1657 else if (mFocusOnAvatar && cameraThirdPerson()) 1651 else if (mFocusOnAvatar && cameraThirdPerson())
1658 { 1652 {
@@ -1700,7 +1694,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction)
1700 1694
1701 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1695 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1702 { 1696 {
1703 mAvatarObject->mHUDTargetZoom = fraction; 1697 mHUDTargetZoom = fraction;
1704 } 1698 }
1705 else if (mFocusOnAvatar && cameraThirdPerson()) 1699 else if (mFocusOnAvatar && cameraThirdPerson())
1706 { 1700 {
@@ -1810,7 +1804,7 @@ void LLAgent::cameraZoomIn(const F32 fraction)
1810 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1804 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1811 { 1805 {
1812 // just update hud zoom level 1806 // just update hud zoom level
1813 mAvatarObject->mHUDTargetZoom /= fraction; 1807 mHUDTargetZoom /= fraction;
1814 return; 1808 return;
1815 } 1809 }
1816 1810
@@ -1956,6 +1950,10 @@ void LLAgent::cameraPanLeft(F32 meters)
1956 1950
1957 mFocusTargetGlobal += meters * left_axis; 1951 mFocusTargetGlobal += meters * left_axis;
1958 mFocusGlobal = mFocusTargetGlobal; 1952 mFocusGlobal = mFocusTargetGlobal;
1953
1954 // disable smoothing for camera pan, which causes some residents unhappiness
1955 mCameraSmoothingStop = TRUE;
1956
1959 cameraZoomIn(1.f); 1957 cameraZoomIn(1.f);
1960 updateFocusOffset(); 1958 updateFocusOffset();
1961} 1959}
@@ -1970,6 +1968,10 @@ void LLAgent::cameraPanUp(F32 meters)
1970 1968
1971 mFocusTargetGlobal += meters * up_axis; 1969 mFocusTargetGlobal += meters * up_axis;
1972 mFocusGlobal = mFocusTargetGlobal; 1970 mFocusGlobal = mFocusTargetGlobal;
1971
1972 // disable smoothing for camera pan, which causes some residents unhappiness
1973 mCameraSmoothingStop = TRUE;
1974
1973 cameraZoomIn(1.f); 1975 cameraZoomIn(1.f);
1974 updateFocusOffset(); 1976 updateFocusOffset();
1975} 1977}
@@ -2092,7 +2094,7 @@ void LLAgent::setAFK()
2092 if (gAFKMenu) 2094 if (gAFKMenu)
2093 { 2095 {
2094 //*TODO:Translate 2096 //*TODO:Translate
2095 gAFKMenu->setLabel(LLString("Set Not Away")); 2097 gAFKMenu->setLabel(std::string("Set Not Away"));
2096 } 2098 }
2097 } 2099 }
2098} 2100}
@@ -2116,7 +2118,7 @@ void LLAgent::clearAFK()
2116 if (gAFKMenu) 2118 if (gAFKMenu)
2117 { 2119 {
2118 //*TODO:Translate 2120 //*TODO:Translate
2119 gAFKMenu->setLabel(LLString("Set Away")); 2121 gAFKMenu->setLabel(std::string("Set Away"));
2120 } 2122 }
2121 } 2123 }
2122} 2124}
@@ -2139,7 +2141,7 @@ void LLAgent::setBusy()
2139 if (gBusyMenu) 2141 if (gBusyMenu)
2140 { 2142 {
2141 //*TODO:Translate 2143 //*TODO:Translate
2142 gBusyMenu->setLabel(LLString("Set Not Busy")); 2144 gBusyMenu->setLabel(std::string("Set Not Busy"));
2143 } 2145 }
2144 LLFloaterMute::getInstance()->updateButtons(); 2146 LLFloaterMute::getInstance()->updateButtons();
2145} 2147}
@@ -2154,7 +2156,7 @@ void LLAgent::clearBusy()
2154 if (gBusyMenu) 2156 if (gBusyMenu)
2155 { 2157 {
2156 //*TODO:Translate 2158 //*TODO:Translate
2157 gBusyMenu->setLabel(LLString("Set Busy")); 2159 gBusyMenu->setLabel(std::string("Set Busy"));
2158 } 2160 }
2159 LLFloaterMute::getInstance()->updateButtons(); 2161 LLFloaterMute::getInstance()->updateButtons();
2160} 2162}
@@ -3228,11 +3230,11 @@ void LLAgent::updateCamera()
3228 LLVector3d agent_pos = getPositionGlobal(); 3230 LLVector3d agent_pos = getPositionGlobal();
3229 LLVector3d camera_pos_agent = camera_pos_global - agent_pos; 3231 LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
3230 3232
3231 if (cameraThirdPerson()) // only smooth in third person mode 3233 if (cameraThirdPerson() && !mCameraSmoothingStop) // only smooth in third person mode
3232 { 3234 {
3233 F32 smoothing = llclampf(1.f - pow(2.f, -4.f * gSavedSettings.getF32("CameraPositionSmoothing") / gFPSClamped)); 3235 const F32 SMOOTHING_HALF_LIFE = 0.02f;
3234 // we use average FPS instead of LLCriticalDamp b/c exact frame time is jittery 3236
3235 3237 F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
3236 3238
3237 if (!mFocusObject) // we differentiate on avatar mode 3239 if (!mFocusObject) // we differentiate on avatar mode
3238 { 3240 {
@@ -3242,7 +3244,7 @@ void LLAgent::updateCamera()
3242 LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent; 3244 LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
3243 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please 3245 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
3244 { 3246 {
3245 camera_pos_agent = lerp(camera_pos_agent, mCameraSmoothingLastPositionAgent, smoothing); 3247 camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing);
3246 camera_pos_global = camera_pos_agent + agent_pos; 3248 camera_pos_global = camera_pos_agent + agent_pos;
3247 } 3249 }
3248 } 3250 }
@@ -3251,13 +3253,14 @@ void LLAgent::updateCamera()
3251 LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal; 3253 LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
3252 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please 3254 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
3253 { 3255 {
3254 camera_pos_global = lerp(camera_pos_global, mCameraSmoothingLastPositionGlobal, smoothing); 3256 camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing);
3255 } 3257 }
3256 } 3258 }
3257 } 3259 }
3258 3260
3259 mCameraSmoothingLastPositionGlobal = camera_pos_global; 3261 mCameraSmoothingLastPositionGlobal = camera_pos_global;
3260 mCameraSmoothingLastPositionAgent = camera_pos_agent; 3262 mCameraSmoothingLastPositionAgent = camera_pos_agent;
3263 mCameraSmoothingStop = FALSE;
3261 } 3264 }
3262 3265
3263 3266
@@ -3295,19 +3298,6 @@ void LLAgent::updateCamera()
3295 setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent); 3298 setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent);
3296 } 3299 }
3297 3300
3298 // Send the camera position to the spatialized voice system.
3299 if(gVoiceClient && getRegion())
3300 {
3301 LLMatrix3 rot;
3302 rot.setRows(LLViewerCamera::getInstance()->getAtAxis(), LLViewerCamera::getInstance()->getLeftAxis (), LLViewerCamera::getInstance()->getUpAxis());
3303
3304 // MBW -- XXX -- Setting velocity to 0 for now. May figure it out later...
3305 gVoiceClient->setCameraPosition(
3306 getRegion()->getPosGlobalFromRegion(LLViewerCamera::getInstance()->getOrigin()),// position
3307 LLVector3::zero, // velocity
3308 rot); // rotation matrix
3309 }
3310
3311 // update the travel distance stat 3301 // update the travel distance stat
3312 // this isn't directly related to the camera 3302 // this isn't directly related to the camera
3313 // but this seemed like the best place to do this 3303 // but this seemed like the best place to do this
@@ -3510,20 +3500,24 @@ LLVector3d LLAgent::calcFocusPositionTargetGlobal()
3510 } 3500 }
3511 else 3501 else
3512 { 3502 {
3513 // ...offset from avatar 3503 return getPositionGlobal() + calcThirdPersonFocusOffset();
3514 LLVector3d focus_offset; 3504 }
3515 focus_offset.setVec(gSavedSettings.getVector3("FocusOffsetDefault")); 3505}
3516
3517 LLQuaternion agent_rot = mFrameAgent.getQuaternion();
3518 if (!mAvatarObject.isNull() && mAvatarObject->getParent())
3519 {
3520 agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation();
3521 }
3522 3506
3523 focus_offset = focus_offset * agent_rot; 3507LLVector3d LLAgent::calcThirdPersonFocusOffset()
3508{
3509 // ...offset from avatar
3510 LLVector3d focus_offset;
3511 focus_offset.setVec(gSavedSettings.getVector3("FocusOffsetDefault"));
3524 3512
3525 return getPositionGlobal() + focus_offset; 3513 LLQuaternion agent_rot = mFrameAgent.getQuaternion();
3514 if (!mAvatarObject.isNull() && mAvatarObject->getParent())
3515 {
3516 agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation();
3526 } 3517 }
3518
3519 focus_offset = focus_offset * agent_rot;
3520 return focus_offset;
3527} 3521}
3528 3522
3529void LLAgent::setupSitCamera() 3523void LLAgent::setupSitCamera()
@@ -3759,7 +3753,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3759 3753
3760 lag_interp *= u; 3754 lag_interp *= u;
3761 3755
3762 if (gViewerWindow->getLeftMouseDown() && gLastHitObjectID == mAvatarObject->getID()) 3756 if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == mAvatarObject->getID())
3763 { 3757 {
3764 // disable camera lag when using mouse-directed steering 3758 // disable camera lag when using mouse-directed steering
3765 target_lag.clearVec(); 3759 target_lag.clearVec();
@@ -3951,6 +3945,11 @@ void LLAgent::resetCamera()
3951//----------------------------------------------------------------------------- 3945//-----------------------------------------------------------------------------
3952void LLAgent::changeCameraToMouselook(BOOL animate) 3946void LLAgent::changeCameraToMouselook(BOOL animate)
3953{ 3947{
3948 if (LLViewerJoystick::getInstance()->getOverrideCamera())
3949 {
3950 return;
3951 }
3952
3954 // visibility changes at end of animation 3953 // visibility changes at end of animation
3955 gViewerWindow->getWindow()->resetBusyCount(); 3954 gViewerWindow->getWindow()->resetBusyCount();
3956 3955
@@ -3977,7 +3976,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate)
3977 3976
3978 if( mCameraMode != CAMERA_MODE_MOUSELOOK ) 3977 if( mCameraMode != CAMERA_MODE_MOUSELOOK )
3979 { 3978 {
3980 gViewerWindow->setKeyboardFocus( NULL ); 3979 gFocusMgr.setKeyboardFocus( NULL );
3981 3980
3982 mLastCameraMode = mCameraMode; 3981 mLastCameraMode = mCameraMode;
3983 mCameraMode = CAMERA_MODE_MOUSELOOK; 3982 mCameraMode = CAMERA_MODE_MOUSELOOK;
@@ -4006,6 +4005,11 @@ void LLAgent::changeCameraToMouselook(BOOL animate)
4006//----------------------------------------------------------------------------- 4005//-----------------------------------------------------------------------------
4007void LLAgent::changeCameraToDefault() 4006void LLAgent::changeCameraToDefault()
4008{ 4007{
4008 if (LLViewerJoystick::getInstance()->getOverrideCamera())
4009 {
4010 return;
4011 }
4012
4009 if (LLFollowCamMgr::getActiveFollowCamParams()) 4013 if (LLFollowCamMgr::getActiveFollowCamParams())
4010 { 4014 {
4011 changeCameraToFollow(); 4015 changeCameraToFollow();
@@ -4023,6 +4027,11 @@ void LLAgent::changeCameraToDefault()
4023//----------------------------------------------------------------------------- 4027//-----------------------------------------------------------------------------
4024void LLAgent::changeCameraToFollow(BOOL animate) 4028void LLAgent::changeCameraToFollow(BOOL animate)
4025{ 4029{
4030 if (LLViewerJoystick::getInstance()->getOverrideCamera())
4031 {
4032 return;
4033 }
4034
4026 if( mCameraMode != CAMERA_MODE_FOLLOW ) 4035 if( mCameraMode != CAMERA_MODE_FOLLOW )
4027 { 4036 {
4028 if (mCameraMode == CAMERA_MODE_MOUSELOOK) 4037 if (mCameraMode == CAMERA_MODE_MOUSELOOK)
@@ -4081,7 +4090,10 @@ void LLAgent::changeCameraToFollow(BOOL animate)
4081//----------------------------------------------------------------------------- 4090//-----------------------------------------------------------------------------
4082void LLAgent::changeCameraToThirdPerson(BOOL animate) 4091void LLAgent::changeCameraToThirdPerson(BOOL animate)
4083{ 4092{
4084//printf( "changeCameraToThirdPerson\n" ); 4093 if (LLViewerJoystick::getInstance()->getOverrideCamera())
4094 {
4095 return;
4096 }
4085 4097
4086 gViewerWindow->getWindow()->resetBusyCount(); 4098 gViewerWindow->getWindow()->resetBusyCount();
4087 4099
@@ -4163,6 +4175,11 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate)
4163//----------------------------------------------------------------------------- 4175//-----------------------------------------------------------------------------
4164void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_animate) 4176void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_animate)
4165{ 4177{
4178 if (LLViewerJoystick::getInstance()->getOverrideCamera())
4179 {
4180 return;
4181 }
4182
4166 setControlFlags(AGENT_CONTROL_STAND_UP); // force stand up 4183 setControlFlags(AGENT_CONTROL_STAND_UP); // force stand up
4167 gViewerWindow->getWindow()->resetBusyCount(); 4184 gViewerWindow->getWindow()->resetBusyCount();
4168 4185
@@ -4198,8 +4215,8 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani
4198 mbFlagsDirty = TRUE; 4215 mbFlagsDirty = TRUE;
4199 } 4216 }
4200 4217
4201 gViewerWindow->setKeyboardFocus( NULL ); 4218 gFocusMgr.setKeyboardFocus( NULL );
4202 gViewerWindow->setMouseCapture( NULL ); 4219 gFocusMgr.setMouseCapture( NULL );
4203 4220
4204 LLVOAvatar::onCustomizeStart(); 4221 LLVOAvatar::onCustomizeStart();
4205 } 4222 }
@@ -4287,6 +4304,12 @@ void LLAgent::setFocusObject(LLViewerObject* object)
4287//----------------------------------------------------------------------------- 4304//-----------------------------------------------------------------------------
4288// setFocusGlobal() 4305// setFocusGlobal()
4289//----------------------------------------------------------------------------- 4306//-----------------------------------------------------------------------------
4307void LLAgent::setFocusGlobal(const LLPickInfo& pick)
4308{
4309 setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
4310}
4311
4312
4290void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) 4313void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
4291{ 4314{
4292 setFocusObject(gObjectList.findObject(object_id)); 4315 setFocusObject(gObjectList.findObject(object_id));
@@ -4473,7 +4496,7 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
4473 //RN: when focused on the avatar, we're not "looking" at it 4496 //RN: when focused on the avatar, we're not "looking" at it
4474 // looking implies intent while focusing on avatar means 4497 // looking implies intent while focusing on avatar means
4475 // you're just walking around with a camera on you...eesh. 4498 // you're just walking around with a camera on you...eesh.
4476 if (focus_on_avatar && !mFocusOnAvatar) 4499 if (!mFocusOnAvatar && focus_on_avatar)
4477 { 4500 {
4478 setFocusGlobal(LLVector3d::zero); 4501 setFocusGlobal(LLVector3d::zero);
4479 mCameraFOVZoomFactor = 0.f; 4502 mCameraFOVZoomFactor = 0.f;
@@ -4497,6 +4520,12 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
4497 } 4520 }
4498 } 4521 }
4499 } 4522 }
4523 // unlocking camera from avatar
4524 else if (mFocusOnAvatar && !focus_on_avatar)
4525 {
4526 // keep camera focus point consistent, even though it is now unlocked
4527 setFocusGlobal(getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
4528 }
4500 4529
4501 mFocusOnAvatar = focus_on_avatar; 4530 mFocusOnAvatar = focus_on_avatar;
4502} 4531}
@@ -4770,6 +4799,9 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const
4770 4799
4771BOOL LLAgent::isInGroup(const LLUUID& group_id) const 4800BOOL LLAgent::isInGroup(const LLUUID& group_id) const
4772{ 4801{
4802 if (isGodlike())
4803 return true;
4804
4773 S32 count = mGroups.count(); 4805 S32 count = mGroups.count();
4774 for(S32 i = 0; i < count; ++i) 4806 for(S32 i = 0; i < count; ++i)
4775 { 4807 {
@@ -4784,6 +4816,9 @@ BOOL LLAgent::isInGroup(const LLUUID& group_id) const
4784// This implementation should mirror LLAgentInfo::hasPowerInGroup 4816// This implementation should mirror LLAgentInfo::hasPowerInGroup
4785BOOL LLAgent::hasPowerInGroup(const LLUUID& group_id, U64 power) const 4817BOOL LLAgent::hasPowerInGroup(const LLUUID& group_id, U64 power) const
4786{ 4818{
4819 if (isGodlike())
4820 return true;
4821
4787 // GP_NO_POWERS can also mean no power is enough to grant an ability. 4822 // GP_NO_POWERS can also mean no power is enough to grant an ability.
4788 if (GP_NO_POWERS == power) return FALSE; 4823 if (GP_NO_POWERS == power) return FALSE;
4789 4824
@@ -4805,6 +4840,9 @@ BOOL LLAgent::hasPowerInActiveGroup(U64 power) const
4805 4840
4806U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const 4841U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const
4807{ 4842{
4843 if (isGodlike())
4844 return GP_ALL_POWERS;
4845
4808 S32 count = mGroups.count(); 4846 S32 count = mGroups.count();
4809 for(S32 i = 0; i < count; ++i) 4847 for(S32 i = 0; i < count; ++i)
4810 { 4848 {
@@ -5104,9 +5142,8 @@ BOOL LLAgent::allowOperation(PermissionBit op,
5104} 5142}
5105 5143
5106 5144
5107void LLAgent::getName(LLString& name) 5145void LLAgent::getName(std::string& name)
5108{ 5146{
5109 // Note: assumes that name points to a buffer of at least DB_FULL_NAME_BUF_SIZE bytes.
5110 name.clear(); 5147 name.clear();
5111 5148
5112 if (mAvatarObject) 5149 if (mAvatarObject)
@@ -5189,8 +5226,8 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **)
5189 { 5226 {
5190 gAgent.mGroupID.setNull(); 5227 gAgent.mGroupID.setNull();
5191 gAgent.mGroupPowers = 0; 5228 gAgent.mGroupPowers = 0;
5192 gAgent.mGroupName[0] = '\0'; 5229 gAgent.mGroupName.clear();
5193 gAgent.mGroupTitle[0] = '\0'; 5230 gAgent.mGroupTitle.clear();
5194 } 5231 }
5195 5232
5196 // refresh all group information 5233 // refresh all group information
@@ -5268,8 +5305,8 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
5268 { 5305 {
5269 gAgent.mGroupID.setNull(); 5306 gAgent.mGroupID.setNull();
5270 gAgent.mGroupPowers = 0; 5307 gAgent.mGroupPowers = 0;
5271 gAgent.mGroupName[0] = '\0'; 5308 gAgent.mGroupName.clear();
5272 gAgent.mGroupTitle[0] = '\0'; 5309 gAgent.mGroupTitle.clear();
5273 } 5310 }
5274 5311
5275 // refresh all group information 5312 // refresh all group information
@@ -5321,7 +5358,6 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **)
5321 LLGroupData group; 5358 LLGroupData group;
5322 S32 index = -1; 5359 S32 index = -1;
5323 bool need_floater_update = false; 5360 bool need_floater_update = false;
5324 char group_name[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
5325 for(S32 i = 0; i < count; ++i) 5361 for(S32 i = 0; i < count; ++i)
5326 { 5362 {
5327 msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group.mID, i); 5363 msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group.mID, i);
@@ -5329,8 +5365,7 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **)
5329 msg->getU64(_PREHASH_GroupData, "GroupPowers", group.mPowers, i); 5365 msg->getU64(_PREHASH_GroupData, "GroupPowers", group.mPowers, i);
5330 msg->getBOOL(_PREHASH_GroupData, "AcceptNotices", group.mAcceptNotices, i); 5366 msg->getBOOL(_PREHASH_GroupData, "AcceptNotices", group.mAcceptNotices, i);
5331 msg->getS32(_PREHASH_GroupData, "Contribution", group.mContribution, i); 5367 msg->getS32(_PREHASH_GroupData, "Contribution", group.mContribution, i);
5332 msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, group_name, i); 5368 msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group.mName, i);
5333 group.mName.assign(group_name);
5334 5369
5335 if(group.mID.notNull()) 5370 if(group.mID.notNull())
5336 { 5371 {
@@ -5428,7 +5463,7 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **)
5428 return; 5463 return;
5429 } 5464 }
5430 5465
5431 msg->getStringFast(_PREHASH_AgentData, _PREHASH_GroupTitle, DB_GROUP_TITLE_BUF_SIZE, gAgent.mGroupTitle); 5466 msg->getStringFast(_PREHASH_AgentData, _PREHASH_GroupTitle, gAgent.mGroupTitle);
5432 LLUUID active_id; 5467 LLUUID active_id;
5433 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_ActiveGroupID, active_id); 5468 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_ActiveGroupID, active_id);
5434 5469
@@ -5437,13 +5472,13 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **)
5437 { 5472 {
5438 gAgent.mGroupID = active_id; 5473 gAgent.mGroupID = active_id;
5439 msg->getU64(_PREHASH_AgentData, "GroupPowers", gAgent.mGroupPowers); 5474 msg->getU64(_PREHASH_AgentData, "GroupPowers", gAgent.mGroupPowers);
5440 msg->getString(_PREHASH_AgentData, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, gAgent.mGroupName); 5475 msg->getString(_PREHASH_AgentData, _PREHASH_GroupName, gAgent.mGroupName);
5441 } 5476 }
5442 else 5477 else
5443 { 5478 {
5444 gAgent.mGroupID.setNull(); 5479 gAgent.mGroupID.setNull();
5445 gAgent.mGroupPowers = 0; 5480 gAgent.mGroupPowers = 0;
5446 gAgent.mGroupName[0] = '\0'; 5481 gAgent.mGroupName.clear();
5447 } 5482 }
5448 5483
5449 update_group_floaters(active_id); 5484 update_group_floaters(active_id);
@@ -6208,7 +6243,7 @@ void LLAgent::saveWearableAs(
6208 return; 6243 return;
6209 } 6244 }
6210 std::string trunc_name(new_name); 6245 std::string trunc_name(new_name);
6211 LLString::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN); 6246 LLStringUtil::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN);
6212 LLWearable* new_wearable = gWearableList.createCopyFromAvatar( 6247 LLWearable* new_wearable = gWearableList.createCopyFromAvatar(
6213 old_wearable, 6248 old_wearable,
6214 trunc_name); 6249 trunc_name);
@@ -6242,7 +6277,7 @@ void LLAgent::saveWearableAs(
6242 LLWearable* old_wearable = getWearable( type ); 6277 LLWearable* old_wearable = getWearable( type );
6243 if( old_wearable ) 6278 if( old_wearable )
6244 { 6279 {
6245 LLString old_name = old_wearable->getName(); 6280 std::string old_name = old_wearable->getName();
6246 old_wearable->setName( new_name ); 6281 old_wearable->setName( new_name );
6247 LLWearable* new_wearable = gWearableList.createCopyFromAvatar( old_wearable ); 6282 LLWearable* new_wearable = gWearableList.createCopyFromAvatar( old_wearable );
6248 old_wearable->setName( old_name ); 6283 old_wearable->setName( old_name );
@@ -6321,7 +6356,7 @@ void LLAgent::setWearableName( const LLUUID& item_id, const std::string& new_nam
6321 LLWearable* old_wearable = mWearableEntry[i].mWearable; 6356 LLWearable* old_wearable = mWearableEntry[i].mWearable;
6322 llassert( old_wearable ); 6357 llassert( old_wearable );
6323 6358
6324 LLString old_name = old_wearable->getName(); 6359 std::string old_name = old_wearable->getName();
6325 old_wearable->setName( new_name ); 6360 old_wearable->setName( new_name );
6326 LLWearable* new_wearable = gWearableList.createCopy( old_wearable ); 6361 LLWearable* new_wearable = gWearableList.createCopy( old_wearable );
6327 LLInventoryItem* item = gInventory.getItem(item_id); 6362 LLInventoryItem* item = gInventory.getItem(item_id);
@@ -6429,27 +6464,14 @@ BOOL LLAgent::isWearingItem( const LLUUID& item_id )
6429 return (getWearableFromWearableItem( item_id ) != NULL); 6464 return (getWearableFromWearableItem( item_id ) != NULL);
6430} 6465}
6431 6466
6432extern LLString gInitialOutfit;
6433
6434// static 6467// static
6435void LLAgent::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void** user_data ) 6468void LLAgent::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void** user_data )
6436{ 6469{
6437 // We should only receive this message a single time. Ignore subsequent AgentWearablesUpdates 6470 // We should only receive this message a single time. Ignore subsequent AgentWearablesUpdates
6438 // that may result from AgentWearablesRequest having been sent more than once. 6471 // that may result from AgentWearablesRequest having been sent more than once.
6439 static BOOL first = TRUE; 6472 static bool first = true;
6440 if( first ) 6473 if (!first) return;
6441 { 6474 first = false;
6442 first = FALSE;
6443 }
6444 else
6445 {
6446 return;
6447 }
6448
6449 if (gNoRender)
6450 {
6451 return;
6452 }
6453 6475
6454 LLUUID agent_id; 6476 LLUUID agent_id;
6455 gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id ); 6477 gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
@@ -6465,16 +6487,6 @@ void LLAgent::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void
6465 // Transitional state. Avatars should always have at least their body parts (hair, eyes, shape and skin). 6487 // Transitional state. Avatars should always have at least their body parts (hair, eyes, shape and skin).
6466 // The fact that they don't have any here (only a dummy is sent) implies that this account existed 6488 // The fact that they don't have any here (only a dummy is sent) implies that this account existed
6467 // before we had wearables, or that the database has gotten messed up. 6489 // before we had wearables, or that the database has gotten messed up.
6468 // Deal with this by creating new body parts.
6469 //avatar->createStandardWearables();
6470
6471 // no, deal with it by noting that we need to choose a
6472 // gender, but only if an initial outfit load isn't happening.
6473 // This whole check (num_wearables < 4) can probably be deleted. JC
6474 if (gInitialOutfit.empty())
6475 {
6476 gAgent.setGenderChosen(FALSE);
6477 }
6478 return; 6490 return;
6479 } 6491 }
6480 6492
@@ -6523,7 +6535,7 @@ void LLAgent::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void
6523 { 6535 {
6524 gWearableList.getAsset( 6536 gWearableList.getAsset(
6525 asset_id_array[i], 6537 asset_id_array[i],
6526 LLString::null, 6538 LLStringUtil::null,
6527 LLWearable::typeToAssetType( (EWearableType) i ), 6539 LLWearable::typeToAssetType( (EWearableType) i ),
6528 LLAgent::onInitialWearableAssetArrived, (void*)(intptr_t)i ); 6540 LLAgent::onInitialWearableAssetArrived, (void*)(intptr_t)i );
6529 } 6541 }
@@ -6765,7 +6777,7 @@ void LLAgent::makeNewOutfit(
6765 new_name = new_folder_name; 6777 new_name = new_folder_name;
6766 new_name.append(" "); 6778 new_name.append(" ");
6767 new_name.append(old_wearable->getTypeLabel()); 6779 new_name.append(old_wearable->getTypeLabel());
6768 LLString::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); 6780 LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN);
6769 new_wearable->setName(new_name); 6781 new_wearable->setName(new_name);
6770 } 6782 }
6771 6783
@@ -7466,7 +7478,7 @@ void LLAgent::observeFriends()
7466 } 7478 }
7467} 7479}
7468 7480
7469void LLAgent::parseTeleportMessages(const LLString& xml_filename) 7481void LLAgent::parseTeleportMessages(const std::string& xml_filename)
7470{ 7482{
7471 LLXMLNodePtr root; 7483 LLXMLNodePtr root;
7472 BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); 7484 BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
@@ -7484,8 +7496,8 @@ void LLAgent::parseTeleportMessages(const LLString& xml_filename)
7484 { 7496 {
7485 if ( !message_set->hasName("message_set") ) continue; 7497 if ( !message_set->hasName("message_set") ) continue;
7486 7498
7487 std::map<LLString, LLString> *teleport_msg_map = NULL; 7499 std::map<std::string, std::string> *teleport_msg_map = NULL;
7488 LLString message_set_name; 7500 std::string message_set_name;
7489 7501
7490 if ( message_set->getAttributeString("name", message_set_name) ) 7502 if ( message_set->getAttributeString("name", message_set_name) )
7491 { 7503 {
@@ -7503,7 +7515,7 @@ void LLAgent::parseTeleportMessages(const LLString& xml_filename)
7503 7515
7504 if ( !teleport_msg_map ) continue; 7516 if ( !teleport_msg_map ) continue;
7505 7517
7506 LLString message_name; 7518 std::string message_name;
7507 for (LLXMLNode* message_node = message_set->getFirstChild(); 7519 for (LLXMLNode* message_node = message_set->getFirstChild();
7508 message_node != NULL; 7520 message_node != NULL;
7509 message_node = message_node->getNextSibling()) 7521 message_node = message_node->getNextSibling())