summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerkeyboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerkeyboard.cpp')
-rw-r--r--indra/newview/llviewerkeyboard.cpp267
1 files changed, 151 insertions, 116 deletions
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index db0da19927..d7e15e7d6c 100644
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -2,46 +2,44 @@
* @file llviewerkeyboard.cpp
* @brief LLViewerKeyboard class implementation
*
- * $LicenseInfo:firstyear=2005&license=viewergpl$
- *
- * Copyright (c) 2005-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
+#include "llappviewer.h"
#include "llviewerkeyboard.h"
#include "llmath.h"
#include "llagent.h"
-#include "llchatbar.h"
+#include "llagentcamera.h"
+#include "llnearbychatbar.h"
#include "llviewercontrol.h"
#include "llfocusmgr.h"
#include "llmorphview.h"
#include "llmoveview.h"
#include "lltoolfocus.h"
#include "llviewerwindow.h"
-#include "llvoavatar.h"
+#include "llvoavatarself.h"
+#include "llfloatercamera.h"
//
// Constants
@@ -87,8 +85,6 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m
{
if (KEYSTATE_UP == s)
{
- // Releasing a walk-key resets the double-tap timer
- gAgent.mDoubleTapRunTimer.reset();
if (gAgent.mDoubleTapRunMode == mode &&
gAgent.getRunning() &&
!gAgent.getAlwaysRun())
@@ -97,16 +93,23 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m
gAgent.clearRunning();
gAgent.sendWalkRun(gAgent.getRunning());
}
- gAgent.mDoubleTapRunMode = mode;
}
- else if (KEYSTATE_DOWN == s &&
- gAgent.mDoubleTapRunMode == mode &&
- gAgent.mDoubleTapRunTimer.getElapsedTimeF32() < NUDGE_TIME)
+ else if (gSavedSettings.getBOOL("AllowTapTapHoldRun") &&
+ KEYSTATE_DOWN == s &&
+ !gAgent.getRunning())
{
- // Same walk-key was pushed again quickly; this is a double-tap
- // so engage temporary running.
- gAgent.setRunning();
- gAgent.sendWalkRun(gAgent.getRunning());
+ if (gAgent.mDoubleTapRunMode == mode &&
+ gAgent.mDoubleTapRunTimer.getElapsedTimeF32() < NUDGE_TIME)
+ {
+ // Same walk-key was pushed again quickly; this is a
+ // double-tap so engage temporary running.
+ gAgent.setRunning();
+ gAgent.sendWalkRun(gAgent.getRunning());
+ }
+
+ // Pressing any walk-key resets the double-tap timer
+ gAgent.mDoubleTapRunTimer.reset();
+ gAgent.mDoubleTapRunMode = mode;
}
}
@@ -128,14 +131,29 @@ static void agent_push_forwardbackward( EKeystate s, S32 direction, LLAgent::EDo
}
}
+void camera_move_forward( EKeystate s );
+
void agent_push_forward( EKeystate s )
{
+ //in free camera control mode we need to intercept keyboard events for avatar movements
+ if (LLFloaterCamera::inFreeCameraMode())
+ {
+ camera_move_forward(s);
+ return;
+ }
agent_push_forwardbackward(s, 1, LLAgent::DOUBLETAP_FORWARD);
}
+void camera_move_backward( EKeystate s );
void agent_push_backward( EKeystate s )
{
+ //in free camera control mode we need to intercept keyboard events for avatar movements
+ if (LLFloaterCamera::inFreeCameraMode())
+ {
+ camera_move_backward(s);
+ return;
+ }
agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD);
}
@@ -168,9 +186,18 @@ void agent_slide_right( EKeystate s )
agent_slide_leftright(s, -1, LLAgent::DOUBLETAP_SLIDERIGHT);
}
+void camera_spin_around_cw( EKeystate s );
+
void agent_turn_left( EKeystate s )
{
- if (gToolCamera->mouseSteerMode())
+ //in free camera control mode we need to intercept keyboard events for avatar movements
+ if (LLFloaterCamera::inFreeCameraMode())
+ {
+ camera_spin_around_cw(s);
+ return;
+ }
+
+ if (LLToolCamera::getInstance()->mouseSteerMode())
{
agent_slide_left(s);
}
@@ -182,10 +209,18 @@ void agent_turn_left( EKeystate s )
}
}
+void camera_spin_around_ccw( EKeystate s );
void agent_turn_right( EKeystate s )
{
- if (gToolCamera->mouseSteerMode())
+ //in free camera control mode we need to intercept keyboard events for avatar movements
+ if (LLFloaterCamera::inFreeCameraMode())
+ {
+ camera_spin_around_ccw(s);
+ return;
+ }
+
+ if (LLToolCamera::getInstance()->mouseSteerMode())
{
agent_slide_right(s);
}
@@ -217,7 +252,7 @@ void agent_toggle_fly( EKeystate s )
// Only catch the edge
if (KEYSTATE_DOWN == s )
{
- gAgent.toggleFlying();
+ LLAgent::toggleFlying();
}
}
@@ -239,22 +274,22 @@ F32 get_orbit_rate()
void camera_spin_around_ccw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitLeftKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitLeftKey( get_orbit_rate() );
}
void camera_spin_around_cw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitRightKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitRightKey( get_orbit_rate() );
}
void camera_spin_around_ccw_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled())
{
//send keystrokes, but do not change camera
agent_turn_right(s);
@@ -262,7 +297,7 @@ void camera_spin_around_ccw_sitting( EKeystate s )
else
{
//change camera but do not send keystrokes
- gAgent.setOrbitLeftKey( get_orbit_rate() );
+ gAgentCamera.setOrbitLeftKey( get_orbit_rate() );
}
}
@@ -270,7 +305,7 @@ void camera_spin_around_ccw_sitting( EKeystate s )
void camera_spin_around_cw_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled())
{
//send keystrokes, but do not change camera
agent_turn_left(s);
@@ -278,7 +313,7 @@ void camera_spin_around_cw_sitting( EKeystate s )
else
{
//change camera but do not send keystrokes
- gAgent.setOrbitRightKey( get_orbit_rate() );
+ gAgentCamera.setOrbitRightKey( get_orbit_rate() );
}
}
@@ -286,22 +321,22 @@ void camera_spin_around_cw_sitting( EKeystate s )
void camera_spin_over( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitUpKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitUpKey( get_orbit_rate() );
}
void camera_spin_under( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitDownKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitDownKey( get_orbit_rate() );
}
void camera_spin_over_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.upGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.upGrabbed() || gAgentCamera.sitCameraEnabled())
{
//send keystrokes, but do not change camera
agent_jump(s);
@@ -309,7 +344,7 @@ void camera_spin_over_sitting( EKeystate s )
else
{
//change camera but do not send keystrokes
- gAgent.setOrbitUpKey( get_orbit_rate() );
+ gAgentCamera.setOrbitUpKey( get_orbit_rate() );
}
}
@@ -317,7 +352,7 @@ void camera_spin_over_sitting( EKeystate s )
void camera_spin_under_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.downGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.downGrabbed() || gAgentCamera.sitCameraEnabled())
{
//send keystrokes, but do not change camera
agent_push_down(s);
@@ -325,35 +360,35 @@ void camera_spin_under_sitting( EKeystate s )
else
{
//change camera but do not send keystrokes
- gAgent.setOrbitDownKey( get_orbit_rate() );
+ gAgentCamera.setOrbitDownKey( get_orbit_rate() );
}
}
void camera_move_forward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitInKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey( get_orbit_rate() );
}
void camera_move_backward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitOutKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitOutKey( get_orbit_rate() );
}
void camera_move_forward_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.forwardGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.forwardGrabbed() || gAgentCamera.sitCameraEnabled())
{
agent_push_forward(s);
}
else
{
- gAgent.setOrbitInKey( get_orbit_rate() );
+ gAgentCamera.setOrbitInKey( get_orbit_rate() );
}
}
@@ -362,70 +397,70 @@ void camera_move_backward_sitting( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- if (gAgent.backwardGrabbed() || gAgent.sitCameraEnabled())
+ if (gAgent.backwardGrabbed() || gAgentCamera.sitCameraEnabled())
{
agent_push_backward(s);
}
else
{
- gAgent.setOrbitOutKey( get_orbit_rate() );
+ gAgentCamera.setOrbitOutKey( get_orbit_rate() );
}
}
void camera_pan_up( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanUpKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanUpKey( get_orbit_rate() );
}
void camera_pan_down( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanDownKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanDownKey( get_orbit_rate() );
}
void camera_pan_left( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanLeftKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanLeftKey( get_orbit_rate() );
}
void camera_pan_right( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanRightKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanRightKey( get_orbit_rate() );
}
void camera_pan_in( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanInKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanInKey( get_orbit_rate() );
}
void camera_pan_out( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanOutKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanOutKey( get_orbit_rate() );
}
void camera_move_forward_fast( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitInKey(2.5f);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey(2.5f);
}
void camera_move_backward_fast( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitOutKey(2.5f);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitOutKey(2.5f);
}
@@ -433,7 +468,7 @@ void edit_avatar_spin_ccw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitLeftKey( get_orbit_rate() );
+ gAgentCamera.setOrbitLeftKey( get_orbit_rate() );
//gMorphView->orbitLeft( get_orbit_rate() );
}
@@ -442,7 +477,7 @@ void edit_avatar_spin_cw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitRightKey( get_orbit_rate() );
+ gAgentCamera.setOrbitRightKey( get_orbit_rate() );
//gMorphView->orbitRight( get_orbit_rate() );
}
@@ -450,7 +485,7 @@ void edit_avatar_spin_over( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitUpKey( get_orbit_rate() );
+ gAgentCamera.setOrbitUpKey( get_orbit_rate() );
//gMorphView->orbitUp( get_orbit_rate() );
}
@@ -459,7 +494,7 @@ void edit_avatar_spin_under( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitDownKey( get_orbit_rate() );
+ gAgentCamera.setOrbitDownKey( get_orbit_rate() );
//gMorphView->orbitDown( get_orbit_rate() );
}
@@ -467,7 +502,7 @@ void edit_avatar_move_forward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitInKey( get_orbit_rate() );
+ gAgentCamera.setOrbitInKey( get_orbit_rate() );
//gMorphView->orbitIn();
}
@@ -476,7 +511,7 @@ void edit_avatar_move_backward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gMorphView->setCameraDrivenByKeys( TRUE );
- gAgent.setOrbitOutKey( get_orbit_rate() );
+ gAgentCamera.setOrbitOutKey( get_orbit_rate() );
//gMorphView->orbitOut();
}
@@ -493,24 +528,25 @@ void stop_moving( EKeystate s )
void start_chat( EKeystate s )
{
// start chat
- gChatBar->startChat(NULL);
+ LLNearbyChatBar::startChat(NULL);
}
void start_gesture( EKeystate s )
{
+ LLUICtrl* focus_ctrlp = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
if (KEYSTATE_UP == s &&
- !gChatBar->inputEditorHasFocus())
+ ! (focus_ctrlp && focus_ctrlp->acceptsTextInput()))
{
- if (gChatBar->getCurrentChat().empty())
- {
- // No existing chat in chat editor, insert '/'
- gChatBar->startChat("/");
- }
- else
- {
- // Don't overwrite existing text in chat editor
- gChatBar->startChat(NULL);
- }
+ if (LLNearbyChatBar::getInstance()->getCurrentChat().empty())
+ {
+ // No existing chat in chat editor, insert '/'
+ LLNearbyChatBar::startChat("/");
+ }
+ else
+ {
+ // Don't overwrite existing text in chat editor
+ LLNearbyChatBar::startChat(NULL);
+ }
}
}
@@ -558,7 +594,8 @@ void bind_keyboard_functions()
gViewerKeyboard.bindNamedFunction("start_gesture", start_gesture);
}
-LLViewerKeyboard::LLViewerKeyboard()
+LLViewerKeyboard::LLViewerKeyboard() :
+ mNamedFunctionCount(0)
{
for (S32 i = 0; i < MODE_COUNT; i++)
{
@@ -577,7 +614,7 @@ LLViewerKeyboard::LLViewerKeyboard()
}
-void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func)
+void LLViewerKeyboard::bindNamedFunction(const std::string& name, LLKeyFunc func)
{
S32 i = mNamedFunctionCount;
mNamedFunctions[i].mName = name;
@@ -586,29 +623,29 @@ void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func)
}
-BOOL LLViewerKeyboard::modeFromString(const char *string, S32 *mode)
+BOOL LLViewerKeyboard::modeFromString(const std::string& string, S32 *mode)
{
- if (!strcmp(string, "FIRST_PERSON"))
+ if (string == "FIRST_PERSON")
{
*mode = MODE_FIRST_PERSON;
return TRUE;
}
- else if (!strcmp(string, "THIRD_PERSON"))
+ else if (string == "THIRD_PERSON")
{
*mode = MODE_THIRD_PERSON;
return TRUE;
}
- else if (!strcmp(string, "EDIT"))
+ else if (string == "EDIT")
{
*mode = MODE_EDIT;
return TRUE;
}
- else if (!strcmp(string, "EDIT_AVATAR"))
+ else if (string == "EDIT_AVATAR")
{
*mode = MODE_EDIT_AVATAR;
return TRUE;
}
- else if (!strcmp(string, "SITTING"))
+ else if (string == "SITTING")
{
*mode = MODE_SITTING;
return TRUE;
@@ -656,11 +693,11 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key, MASK translated_mask, BOOL
-BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const char *function_name)
+BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name)
{
S32 i,index;
void (*function)(EKeystate keystate) = NULL;
- const char *name = NULL;
+ std::string name;
// Allow remapping of F2-F12
if (function_name[0] == 'F')
@@ -675,7 +712,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
if (idx >=2 && idx <= 12)
{
U32 keyidx = ((mask<<16)|key);
- (mRemapKeys[mode])[keyidx] = ((0<<16)|KEY_F1+(idx-1));
+ (mRemapKeys[mode])[keyidx] = ((0<<16)|(KEY_F1+(idx-1)));
return TRUE;
}
}
@@ -684,7 +721,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
// Not remapped, look for a function
for (i = 0; i < mNamedFunctionCount; i++)
{
- if (!strcmp(function_name, mNamedFunctions[i].mName))
+ if (function_name == mNamedFunctions[i].mName)
{
function = mNamedFunctions[i].mFunction;
name = mNamedFunctions[i].mName;
@@ -724,22 +761,20 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
if (index == mBindingCount[mode])
mBindingCount[mode]++;
- // printf("Bound key %c to %s\n", key, name);
-
return TRUE;
}
-S32 LLViewerKeyboard::loadBindings(const char *filename)
+S32 LLViewerKeyboard::loadBindings(const std::string& filename)
{
- FILE *fp;
+ LLFILE *fp;
const S32 BUFFER_SIZE = 2048;
char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */
// *NOTE: This buffer size is hard coded into scanf() below.
- char mode_string[MAX_STRING]; /* Flawfinder: ignore */
- char key_string[MAX_STRING]; /* Flawfinder: ignore */
- char mask_string[MAX_STRING]; /* Flawfinder: ignore */
- char function_string[MAX_STRING]; /* Flawfinder: ignore */
+ char mode_string[MAX_STRING] = ""; /* Flawfinder: ignore */
+ char key_string[MAX_STRING] = ""; /* Flawfinder: ignore */
+ char mask_string[MAX_STRING] = ""; /* Flawfinder: ignore */
+ char function_string[MAX_STRING] = ""; /* Flawfinder: ignore */
S32 mode = MODE_THIRD_PERSON;
KEY key = 0;
MASK mask = 0;
@@ -747,7 +782,7 @@ S32 LLViewerKeyboard::loadBindings(const char *filename)
S32 binding_count = 0;
S32 line_count = 0;
- if(!filename)
+ if(filename.empty())
{
llerrs << " No filename specified" << llendl;
return 0;
@@ -828,7 +863,7 @@ S32 LLViewerKeyboard::loadBindings(const char *filename)
EKeyboardMode LLViewerKeyboard::getMode()
{
- if ( gAgent.cameraMouselook() )
+ if ( gAgentCamera.cameraMouselook() )
{
return MODE_FIRST_PERSON;
}
@@ -836,7 +871,7 @@ EKeyboardMode LLViewerKeyboard::getMode()
{
return MODE_EDIT_AVATAR;
}
- else if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mIsSitting)
+ else if (isAgentAvatarValid() && gAgentAvatarp->isSitting())
{
return MODE_SITTING;
}