PageRenderTime 463ms CodeModel.GetById 141ms app.highlight 213ms RepoModel.GetById 99ms app.codeStats 1ms

/indra/newview/llagent.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 845 lines | 486 code | 101 blank | 258 comment | 2 complexity | ed4db2e482ac4bf6ff1ed40c9c587b11 MD5 | raw file
  1/** 
  2 * @file llagent.h
  3 * @brief LLAgent class header file
  4 *
  5 * $LicenseInfo:firstyear=2000&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLAGENT_H
 28#define LL_LLAGENT_H
 29
 30#include "indra_constants.h"
 31#include "llevent.h" 				// LLObservable base class
 32#include "llagentconstants.h"
 33#include "llagentdata.h" 			// gAgentID, gAgentSessionID
 34#include "llcharacter.h"
 35#include "llcoordframe.h"			// for mFrameAgent
 36#include "llvoavatardefines.h"
 37
 38#include <boost/signals2.hpp>
 39
 40extern const BOOL 	ANIMATE;
 41extern const U8 	AGENT_STATE_TYPING;  // Typing indication
 42extern const U8 	AGENT_STATE_EDITING; // Set when agent has objects selected
 43
 44class LLChat;
 45class LLViewerRegion;
 46class LLMotion;
 47class LLToolset;
 48class LLMessageSystem;
 49class LLPermissions;
 50class LLHost;
 51class LLFriendObserver;
 52class LLPickInfo;
 53class LLViewerObject;
 54class LLAgentDropGroupViewerNode;
 55class LLAgentAccess;
 56class LLSLURL;
 57class LLPauseRequestHandle;
 58class LLUIColor;
 59
 60//--------------------------------------------------------------------
 61// Types
 62//--------------------------------------------------------------------
 63
 64enum EAnimRequest
 65{
 66	ANIM_REQUEST_START,
 67	ANIM_REQUEST_STOP
 68};
 69
 70struct LLGroupData
 71{
 72	LLUUID mID;
 73	LLUUID mInsigniaID;
 74	U64 mPowers;
 75	BOOL mAcceptNotices;
 76	BOOL mListInProfile;
 77	S32 mContribution;
 78	std::string mName;
 79};
 80
 81class LLAgentListener;
 82
 83class LLAgentImpl;
 84
 85//------------------------------------------------------------------------
 86// LLAgent
 87//------------------------------------------------------------------------
 88class LLAgent : public LLOldEvents::LLObservable
 89{
 90	LOG_CLASS(LLAgent);
 91
 92public:
 93	friend class LLAgentDropGroupViewerNode;
 94
 95/********************************************************************************
 96 **                                                                            **
 97 **                    INITIALIZATION
 98 **/
 99
100	//--------------------------------------------------------------------
101	// Constructors / Destructors
102	//--------------------------------------------------------------------
103public:
104	LLAgent();
105	virtual 		~LLAgent();
106	void			init();
107	void			cleanup();
108
109	//--------------------------------------------------------------------
110	// Login
111	//--------------------------------------------------------------------
112public:
113	void			onAppFocusGained();
114	void			setFirstLogin(BOOL b) 	{ mFirstLogin = b; }
115	// Return TRUE if the database reported this login as the first for this particular user.
116	BOOL 			isFirstLogin() const 	{ return mFirstLogin; }
117	BOOL 			isInitialized() const 	{ return mInitialized; }
118public:
119	std::string		mMOTD; 					// Message of the day
120private:
121	BOOL			mInitialized;
122	BOOL			mFirstLogin;
123	boost::shared_ptr<LLAgentListener> mListener;
124
125	//--------------------------------------------------------------------
126	// Session
127	//--------------------------------------------------------------------
128public:
129	const LLUUID&	getID() const				{ return gAgentID; }
130	const LLUUID&	getSessionID() const		{ return gAgentSessionID; }
131	// Note: NEVER send this value in the clear or over any weakly
132	// encrypted channel (such as simple XOR masking).  If you are unsure
133	// ask Aaron or MarkL.
134	const LLUUID&	getSecureSessionID() const	{ return mSecureSessionID; }
135public:
136	LLUUID			mSecureSessionID; 			// Secure token for this login session
137	
138/**                    Initialization
139 **                                                                            **
140 *******************************************************************************/
141
142/********************************************************************************
143 **                                                                            **
144 **                    IDENTITY
145 **/
146
147	//--------------------------------------------------------------------
148	// Name
149	//--------------------------------------------------------------------
150public:
151	//*TODO remove, is not used as of August 20, 2009
152	void			buildFullnameAndTitle(std::string &name) const;
153
154	//--------------------------------------------------------------------
155	// Gender
156	//--------------------------------------------------------------------
157public:
158	// On the very first login, gender isn't chosen until the user clicks
159	// in a dialog.  We don't render the avatar until they choose.
160	BOOL 			isGenderChosen() const 	{ return mGenderChosen; }
161	void			setGenderChosen(BOOL b)	{ mGenderChosen = b; }
162private:
163	BOOL			mGenderChosen;
164
165/**                    Identity
166 **                                                                            **
167 *******************************************************************************/
168
169/********************************************************************************
170 **                                                                            **
171 **                    POSITION
172 **/
173
174  	//--------------------------------------------------------------------
175 	// Position
176	//--------------------------------------------------------------------
177public:
178	LLVector3		getPosAgentFromGlobal(const LLVector3d &pos_global) const;
179	LLVector3d		getPosGlobalFromAgent(const LLVector3 &pos_agent) const;	
180	const LLVector3d &getPositionGlobal() const;
181	const LLVector3	&getPositionAgent();
182	// Call once per frame to update position, angles (radians).
183	void			updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y);	
184	void			setPositionAgent(const LLVector3 &center);
185protected:
186	void			propagate(const F32 dt); // ! BUG ! Should roll into updateAgentPosition
187private:
188	mutable LLVector3d mPositionGlobal;
189
190  	//--------------------------------------------------------------------
191 	// Velocity
192	//--------------------------------------------------------------------
193public:
194	LLVector3		getVelocity() const;
195	F32				getVelocityZ() const 	{ return getVelocity().mV[VZ]; } // ! HACK !
196	
197  	//--------------------------------------------------------------------
198	// Coordinate System
199	//--------------------------------------------------------------------
200public:
201	const LLCoordFrame&	getFrameAgent()	const	{ return mFrameAgent; }
202	void 			initOriginGlobal(const LLVector3d &origin_global); // Only to be used in ONE place
203	void			resetAxes();
204	void			resetAxes(const LLVector3 &look_at); // Makes reasonable left and up
205	// The following three get*Axis functions return direction avatar is looking, not camera.
206	const LLVector3& getAtAxis() const		{ return mFrameAgent.getAtAxis(); }
207	const LLVector3& getUpAxis() const		{ return mFrameAgent.getUpAxis(); }
208	const LLVector3& getLeftAxis() const	{ return mFrameAgent.getLeftAxis(); }
209	LLQuaternion	getQuat() const; 		// Returns the quat that represents the rotation of the agent in the absolute frame
210private:
211	LLVector3d		mAgentOriginGlobal;		// Origin of agent coords from global coords
212	LLCoordFrame	mFrameAgent; 			// Agent position and view, agent-region coordinates
213
214
215	//--------------------------------------------------------------------
216	// Home
217	//--------------------------------------------------------------------
218public:
219	void			setStartPosition(U32 location_id); // Marks current location as start, sends information to servers
220	void			setHomePosRegion(const U64& region_handle, const LLVector3& pos_region);
221	BOOL			getHomePosGlobal(LLVector3d* pos_global);
222private:
223	BOOL 			mHaveHomePosition;
224	U64				mHomeRegionHandle;
225	LLVector3		mHomePosRegion;
226
227	//--------------------------------------------------------------------
228	// Region
229	//--------------------------------------------------------------------
230public:
231	void			setRegion(LLViewerRegion *regionp);
232	LLViewerRegion	*getRegion() const;
233	LLHost			getRegionHost() const;
234	BOOL			inPrelude();
235private:
236	LLViewerRegion	*mRegionp;
237
238	//--------------------------------------------------------------------
239	// History
240	//--------------------------------------------------------------------
241public:
242	S32				getRegionsVisited() const;
243	F64				getDistanceTraveled() const;	
244	void			setDistanceTraveled(F64 dist) { mDistanceTraveled = dist; }
245	
246	const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; }
247	void			setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; }
248private:
249	std::set<U64>	mRegionsVisited;		// Stat - what distinct regions has the avatar been to?
250	F64				mDistanceTraveled;		// Stat - how far has the avatar moved?
251	LLVector3d		mLastPositionGlobal;	// Used to calculate travel distance
252	
253/**                    Position
254 **                                                                            **
255 *******************************************************************************/
256
257/********************************************************************************
258 **                                                                            **
259 **                    ACTIONS
260 **/
261
262	//--------------------------------------------------------------------
263	// Fidget
264	//--------------------------------------------------------------------
265	// Trigger random fidget animations
266public:
267	void			fidget();
268	static void		stopFidget();
269private:
270	LLFrameTimer	mFidgetTimer;
271	LLFrameTimer	mFocusObjectFadeTimer;
272	LLFrameTimer	mMoveTimer;
273	F32				mNextFidgetTime;
274	S32				mCurrentFidget;
275
276	//--------------------------------------------------------------------
277	// Fly
278	//--------------------------------------------------------------------
279public:
280	BOOL			getFlying() const;
281	void			setFlying(BOOL fly);
282	static void		toggleFlying();
283	static bool		enableFlying();
284	BOOL			canFly(); 			// Does this parcel allow you to fly?
285
286	//--------------------------------------------------------------------
287	// Voice
288	//--------------------------------------------------------------------
289public:
290	bool 			isVoiceConnected() const { return mVoiceConnected; }
291	void			setVoiceConnected(const bool b)	{ mVoiceConnected = b; }
292
293	static void		pressMicrophone(const LLSD& name);
294	static void		releaseMicrophone(const LLSD& name);
295	static void		toggleMicrophone(const LLSD& name);
296	static bool		isMicrophoneOn(const LLSD& sdname);
297	static bool		isActionAllowed(const LLSD& sdname);
298
299private:
300	bool			mVoiceConnected;
301
302	//--------------------------------------------------------------------
303	// Chat
304	//--------------------------------------------------------------------
305public:
306	void			heardChat(const LLUUID& id);
307	F32				getTypingTime() 		{ return mTypingTimer.getElapsedTimeF32(); }
308	LLUUID			getLastChatter() const 	{ return mLastChatterID; }
309	F32				getNearChatRadius() 	{ return mNearChatRadius; }
310protected:
311	void 			ageChat(); 				// Helper function to prematurely age chat when agent is moving
312private:
313	LLFrameTimer	mChatTimer;
314	LLUUID			mLastChatterID;
315	F32				mNearChatRadius;
316	
317	//--------------------------------------------------------------------
318	// Typing
319	//--------------------------------------------------------------------
320public:
321	void			startTyping();
322	void			stopTyping();
323public:
324	// When the agent hasn't typed anything for this duration, it leaves the 
325	// typing state (for both chat and IM).
326	static const F32 TYPING_TIMEOUT_SECS;
327private:
328	LLFrameTimer	mTypingTimer;
329
330	//--------------------------------------------------------------------
331	// AFK
332	//--------------------------------------------------------------------
333public:
334	void			setAFK();
335	void			clearAFK();
336	BOOL			getAFK() const;
337	static const F32 MIN_AFK_TIME;
338	
339	//--------------------------------------------------------------------
340	// Run
341	//--------------------------------------------------------------------
342public:
343	enum EDoubleTapRunMode
344	{
345		DOUBLETAP_NONE,
346		DOUBLETAP_FORWARD,
347		DOUBLETAP_BACKWARD,
348		DOUBLETAP_SLIDELEFT,
349		DOUBLETAP_SLIDERIGHT
350	};
351
352	void			setAlwaysRun() 			{ mbAlwaysRun = true; }
353	void			clearAlwaysRun() 		{ mbAlwaysRun = false; }
354	void			setRunning() 			{ mbRunning = true; }
355	void			clearRunning() 			{ mbRunning = false; }
356	void 			sendWalkRun(bool running);
357	bool			getAlwaysRun() const 	{ return mbAlwaysRun; }
358	bool			getRunning() const 		{ return mbRunning; }
359public:
360	LLFrameTimer 	mDoubleTapRunTimer;
361	EDoubleTapRunMode mDoubleTapRunMode;
362private:
363	bool 			mbAlwaysRun; 			// Should the avatar run by default rather than walk?
364	bool 			mbRunning;				// Is the avatar trying to run right now?
365	bool			mbTeleportKeepsLookAt;	// Try to keep look-at after teleport is complete
366
367	//--------------------------------------------------------------------
368	// Sit and stand
369	//--------------------------------------------------------------------
370public:
371	void			standUp();
372	/// @brief ground-sit at agent's current position
373	void			sitDown();
374
375	//--------------------------------------------------------------------
376	// Busy
377	//--------------------------------------------------------------------
378public:
379	void			setBusy();
380	void			clearBusy();
381	BOOL			getBusy() const;
382private:
383	BOOL			mIsBusy;
384
385	//--------------------------------------------------------------------
386	// Grab
387	//--------------------------------------------------------------------
388public:
389	BOOL 			leftButtonGrabbed() const;
390	BOOL 			rotateGrabbed() const;
391	BOOL 			forwardGrabbed() const;
392	BOOL 			backwardGrabbed() const;
393	BOOL 			upGrabbed() const;
394	BOOL 			downGrabbed() const;
395
396	//--------------------------------------------------------------------
397	// Controls
398	//--------------------------------------------------------------------
399public:
400	U32 			getControlFlags(); 
401	void 			setControlFlags(U32 mask); 		// Performs bitwise mControlFlags |= mask
402	void 			clearControlFlags(U32 mask); 	// Performs bitwise mControlFlags &= ~mask
403	BOOL			controlFlagsDirty() const;
404	void			enableControlFlagReset();
405	void 			resetControlFlags();
406	BOOL			anyControlGrabbed() const; 		// True iff a script has taken over a control
407	BOOL			isControlGrabbed(S32 control_index) const;
408	// Send message to simulator to force grabbed controls to be
409	// released, in case of a poorly written script.
410	void			forceReleaseControls();
411	void			setFlagsDirty() { mbFlagsDirty = TRUE; }
412
413private:
414	S32				mControlsTakenCount[TOTAL_CONTROLS];
415	S32				mControlsTakenPassedOnCount[TOTAL_CONTROLS];
416	U32				mControlFlags;					// Replacement for the mFooKey's
417	BOOL 			mbFlagsDirty;
418	BOOL 			mbFlagsNeedReset;				// ! HACK ! For preventing incorrect flags sent when crossing region boundaries
419	
420	//--------------------------------------------------------------------
421	// Animations
422	//--------------------------------------------------------------------
423public:
424	void            stopCurrentAnimations();
425	void			requestStopMotion(LLMotion* motion);
426	void			onAnimStop(const LLUUID& id);
427	void			sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
428	void			sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
429	void			endAnimationUpdateUI();
430	void			unpauseAnimation() { mPauseRequest = NULL; }
431	BOOL			getCustomAnim() const { return mCustomAnim; }
432	void			setCustomAnim(BOOL anim) { mCustomAnim = anim; }
433	
434	typedef boost::signals2::signal<void ()> camera_signal_t;
435	boost::signals2::connection setMouselookModeInCallback( const camera_signal_t::slot_type& cb );
436	boost::signals2::connection setMouselookModeOutCallback( const camera_signal_t::slot_type& cb );
437
438private:
439	camera_signal_t* mMouselookModeInSignal;
440	camera_signal_t* mMouselookModeOutSignal;
441	BOOL            mCustomAnim; 		// Current animation is ANIM_AGENT_CUSTOMIZE ?
442	LLPointer<LLPauseRequestHandle> mPauseRequest;
443	BOOL			mViewsPushed; 		// Keep track of whether or not we have pushed views
444	
445/**                    Animation
446 **                                                                            **
447 *******************************************************************************/
448
449/********************************************************************************
450 **                                                                            **
451 **                    MOVEMENT
452 **/
453
454	//--------------------------------------------------------------------
455	// Movement from user input
456	//--------------------------------------------------------------------
457	// All set the appropriate animation flags.
458	// All turn off autopilot and make sure the camera is behind the avatar.
459	// Direction is either positive, zero, or negative
460public:
461	void			moveAt(S32 direction, bool reset_view = true);
462	void			moveAtNudge(S32 direction);
463	void			moveLeft(S32 direction);
464	void			moveLeftNudge(S32 direction);
465	void			moveUp(S32 direction);
466	void			moveYaw(F32 mag, bool reset_view = true);
467	void			movePitch(F32 mag);
468
469	//--------------------------------------------------------------------
470 	// Move the avatar's frame
471	//--------------------------------------------------------------------
472public:
473	void			rotate(F32 angle, const LLVector3 &axis);
474	void			rotate(F32 angle, F32 x, F32 y, F32 z);
475	void			rotate(const LLMatrix3 &matrix);
476	void			rotate(const LLQuaternion &quaternion);
477	void			pitch(F32 angle);
478	void			roll(F32 angle);
479	void			yaw(F32 angle);
480	LLVector3		getReferenceUpVector();
481    F32             clampPitchToLimits(F32 angle);
482
483	//--------------------------------------------------------------------
484	// Autopilot
485	//--------------------------------------------------------------------
486public:
487	BOOL			getAutoPilot() const				{ return mAutoPilot; }
488	LLVector3d		getAutoPilotTargetGlobal() const 	{ return mAutoPilotTargetGlobal; }
489	LLUUID			getAutoPilotLeaderID() const		{ return mLeaderID; }
490	F32				getAutoPilotStopDistance() const	{ return mAutoPilotStopDistance; }
491	F32				getAutoPilotTargetDist() const		{ return mAutoPilotTargetDist; }
492	BOOL			getAutoPilotUseRotation() const		{ return mAutoPilotUseRotation; }
493	LLVector3		getAutoPilotTargetFacing() const	{ return mAutoPilotTargetFacing; }
494	F32				getAutoPilotRotationThreshold() const	{ return mAutoPilotRotationThreshold; }
495	std::string		getAutoPilotBehaviorName() const	{ return mAutoPilotBehaviorName; }
496
497	void			startAutoPilotGlobal(const LLVector3d &pos_global, 
498										 const std::string& behavior_name = std::string(), 
499										 const LLQuaternion *target_rotation = NULL, 
500										 void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, 
501										 F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f,
502										 BOOL allow_flying = TRUE);
503	void 			startFollowPilot(const LLUUID &leader_id, BOOL allow_flying = TRUE, F32 stop_distance = 0.5f);
504	void			stopAutoPilot(BOOL user_cancel = FALSE);
505	void 			setAutoPilotTargetGlobal(const LLVector3d &target_global);
506	void			autoPilot(F32 *delta_yaw); 			// Autopilot walking action, angles in radians
507	void			renderAutoPilotTarget();
508private:
509	BOOL			mAutoPilot;
510	BOOL			mAutoPilotFlyOnStop;
511	BOOL			mAutoPilotAllowFlying;
512	LLVector3d		mAutoPilotTargetGlobal;
513	F32				mAutoPilotStopDistance;
514	BOOL			mAutoPilotUseRotation;
515	LLVector3		mAutoPilotTargetFacing;
516	F32				mAutoPilotTargetDist;
517	S32				mAutoPilotNoProgressFrameCount;
518	F32				mAutoPilotRotationThreshold;
519	std::string		mAutoPilotBehaviorName;
520	void			(*mAutoPilotFinishedCallback)(BOOL, void *);
521	void*			mAutoPilotCallbackData;
522	LLUUID			mLeaderID;
523	
524/**                    Movement
525 **                                                                            **
526 *******************************************************************************/
527
528/********************************************************************************
529 **                                                                            **
530 **                    TELEPORT
531 **/
532
533public:
534	enum ETeleportState
535	{
536		TELEPORT_NONE = 0,			// No teleport in progress
537		TELEPORT_START = 1,			// Transition to REQUESTED.  Viewer has sent a TeleportRequest to the source simulator
538		TELEPORT_REQUESTED = 2,		// Waiting for source simulator to respond
539		TELEPORT_MOVING = 3,		// Viewer has received destination location from source simulator
540		TELEPORT_START_ARRIVAL = 4,	// Transition to ARRIVING.  Viewer has received avatar update, etc., from destination simulator
541		TELEPORT_ARRIVING = 5,		// Make the user wait while content "pre-caches"
542		TELEPORT_LOCAL = 6			// Teleporting in-sim without showing the progress screen
543	};
544
545public:
546	static void 	parseTeleportMessages(const std::string& xml_filename);
547	const void getTeleportSourceSLURL(LLSLURL& slurl) const;
548public:
549	// ! TODO ! Define ERROR and PROGRESS enums here instead of exposing the mappings.
550	static std::map<std::string, std::string> sTeleportErrorMessages;
551	static std::map<std::string, std::string> sTeleportProgressMessages;
552private:
553	LLSLURL * mTeleportSourceSLURL; 			// SLURL where last TP began
554
555	//--------------------------------------------------------------------
556	// Teleport Actions
557	//--------------------------------------------------------------------
558public:
559	void 			teleportRequest(const U64& region_handle,
560									const LLVector3& pos_local,				// Go to a named location home
561									bool look_at_from_camera = false);
562	void 			teleportViaLandmark(const LLUUID& landmark_id);			// Teleport to a landmark
563	void 			teleportHome()	{ teleportViaLandmark(LLUUID::null); }	// Go home
564	void 			teleportViaLure(const LLUUID& lure_id, BOOL godlike);	// To an invited location
565	void 			teleportViaLocation(const LLVector3d& pos_global);		// To a global location - this will probably need to be deprecated
566	void			teleportViaLocationLookAt(const LLVector3d& pos_global);// To a global location, preserving camera rotation
567	void 			teleportCancel();										// May or may not be allowed by server
568	bool			getTeleportKeepsLookAt() { return mbTeleportKeepsLookAt; } // Whether look-at reset after teleport
569protected:
570	bool 			teleportCore(bool is_local = false); 					// Stuff for all teleports; returns true if the teleport can proceed
571
572	//--------------------------------------------------------------------
573	// Teleport State
574	//--------------------------------------------------------------------
575public:
576	ETeleportState	getTeleportState() const 						{ return mTeleportState; }
577	void			setTeleportState(ETeleportState state);
578private:
579	ETeleportState	mTeleportState;
580
581	//--------------------------------------------------------------------
582	// Teleport Message
583	//--------------------------------------------------------------------
584public:
585	const std::string& getTeleportMessage() const 					{ return mTeleportMessage; }
586	void 			setTeleportMessage(const std::string& message) 	{ mTeleportMessage = message; }
587private:
588	std::string		mTeleportMessage;
589	
590/**                    Teleport
591 **                                                                            **
592 *******************************************************************************/
593
594	// Build
595public:
596	bool			canEditParcel() const { return mCanEditParcel; }
597private:
598	bool			mCanEditParcel;
599
600	static void parcelChangedCallback();
601
602/********************************************************************************
603 **                                                                            **
604 **                    ACCESS
605 **/
606
607public:
608	// Checks if agent can modify an object based on the permissions and the agent's proxy status.
609	BOOL			isGrantedProxy(const LLPermissions& perm);
610	BOOL			allowOperation(PermissionBit op,
611								   const LLPermissions& perm,
612								   U64 group_proxy_power = 0,
613								   U8 god_minimum = GOD_MAINTENANCE);
614	const LLAgentAccess& getAgentAccess();
615	BOOL			canManageEstate() const;
616	BOOL			getAdminOverride() const;
617	// ! BACKWARDS COMPATIBILITY ! This function can go away after the AO transition (see llstartup.cpp).
618	void 			setAOTransition();
619private:
620	LLAgentAccess * mAgentAccess;
621	
622	//--------------------------------------------------------------------
623	// God
624	//--------------------------------------------------------------------
625public:
626	bool			isGodlike() const;
627	bool			isGodlikeWithoutAdminMenuFakery() const;
628	U8				getGodLevel() const;
629	void			setAdminOverride(BOOL b);
630	void			setGodLevel(U8 god_level);
631	void			requestEnterGodMode();
632	void			requestLeaveGodMode();
633
634	//--------------------------------------------------------------------
635	// Maturity
636	//--------------------------------------------------------------------
637public:
638	// Note: this is a prime candidate for pulling out into a Maturity class.
639	// Rather than just expose the preference setting, we're going to actually
640	// expose what the client code cares about -- what the user should see
641	// based on a combination of the is* and prefers* flags, combined with god bit.
642	bool 			wantsPGOnly() const;
643	bool 			canAccessMature() const;
644	bool 			canAccessAdult() const;
645	bool 			canAccessMaturityInRegion( U64 region_handle ) const;
646	bool 			canAccessMaturityAtGlobal( LLVector3d pos_global ) const;
647	bool 			prefersPG() const;
648	bool 			prefersMature() const;
649	bool 			prefersAdult() const;
650	bool 			isTeen() const;
651	bool 			isMature() const;
652	bool 			isAdult() const;
653	void 			setTeen(bool teen);
654	void 			setMaturity(char text);
655	static int 		convertTextToMaturity(char text); 
656	bool 			sendMaturityPreferenceToServer(int preferredMaturity); // ! "U8" instead of "int"?
657
658	// Maturity callbacks for PreferredMaturity control variable
659	void 			handleMaturity(const LLSD& newvalue);
660	bool 			validateMaturity(const LLSD& newvalue);
661
662
663/**                    Access
664 **                                                                            **
665 *******************************************************************************/
666
667/********************************************************************************
668 **                                                                            **
669 **                    RENDERING
670 **/
671
672public:
673	LLQuaternion	getHeadRotation();
674	BOOL			needsRenderAvatar(); // TRUE when camera mode is such that your own avatar should draw
675	BOOL			needsRenderHead();
676	void			setShowAvatar(BOOL show) { mShowAvatar = show; }
677	BOOL			getShowAvatar() const { return mShowAvatar; }
678	
679private:
680	BOOL			mShowAvatar; 		// Should we render the avatar?
681	U32				mAppearanceSerialNum;
682	
683	//--------------------------------------------------------------------
684	// Rendering state bitmap helpers
685	//--------------------------------------------------------------------
686public:
687	void			setRenderState(U8 newstate);
688	void			clearRenderState(U8 clearstate);
689	U8				getRenderState();
690private:
691	U8				mRenderState; // Current behavior state of agent
692
693	//--------------------------------------------------------------------
694	// HUD
695	//--------------------------------------------------------------------
696public:
697	const LLColor4	&getEffectColor();
698	void			setEffectColor(const LLColor4 &color);
699private:
700	LLUIColor * mEffectColor;
701
702/**                    Rendering
703 **                                                                            **
704 *******************************************************************************/
705
706/********************************************************************************
707 **                                                                            **
708 **                    GROUPS
709 **/
710
711public:
712	const LLUUID	&getGroupID() const			{ return mGroupID; }
713	// Get group information by group_id, or FALSE if not in group.
714	BOOL 			getGroupData(const LLUUID& group_id, LLGroupData& data) const;
715	// Get just the agent's contribution to the given group.
716	S32 			getGroupContribution(const LLUUID& group_id) const;
717	// Update internal datastructures and update the server.
718	BOOL 			setGroupContribution(const LLUUID& group_id, S32 contribution);
719	BOOL 			setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
720	const std::string &getGroupName() const 	{ return mGroupName; }
721	BOOL			canJoinGroups() const;
722private:
723	std::string		mGroupName;
724	LLUUID			mGroupID;
725
726	//--------------------------------------------------------------------
727	// Group Membership
728	//--------------------------------------------------------------------
729public:
730	// Checks against all groups in the entire agent group list.
731	BOOL 			isInGroup(const LLUUID& group_id, BOOL ingnore_God_mod = FALSE) const;
732protected:
733	// Only used for building titles.
734	BOOL			isGroupMember() const 		{ return !mGroupID.isNull(); } 
735public:
736	LLDynamicArray<LLGroupData> mGroups;
737
738	//--------------------------------------------------------------------
739	// Group Title
740	//--------------------------------------------------------------------
741public:
742	void			setHideGroupTitle(BOOL hide)	{ mHideGroupTitle = hide; }
743	BOOL			isGroupTitleHidden() const 		{ return mHideGroupTitle; }
744private:
745	std::string		mGroupTitle; 					// Honorific, like "Sir"
746	BOOL			mHideGroupTitle;
747
748	//--------------------------------------------------------------------
749	// Group Powers
750	//--------------------------------------------------------------------
751public:
752	BOOL 			hasPowerInGroup(const LLUUID& group_id, U64 power) const;
753	BOOL 			hasPowerInActiveGroup(const U64 power) const;
754	U64  			getPowerInGroup(const LLUUID& group_id) const;
755 	U64				mGroupPowers;
756
757	//--------------------------------------------------------------------
758	// Friends
759	//--------------------------------------------------------------------
760public:
761	void 			observeFriends();
762	void 			friendsChanged();
763private:
764	LLFriendObserver* mFriendObserver;
765	std::set<LLUUID> mProxyForAgents;
766
767/**                    Groups
768 **                                                                            **
769 *******************************************************************************/
770
771/********************************************************************************
772 **                                                                            **
773 **                    MESSAGING
774 **/
775
776	//--------------------------------------------------------------------
777	// Send
778	//--------------------------------------------------------------------
779public:
780	void			sendMessage(); // Send message to this agent's region
781	void			sendReliableMessage();
782	void			sendAgentSetAppearance();
783	void 			sendAgentDataUpdateRequest();
784	void 			sendAgentUserInfoRequest();
785	// IM to Email and Online visibility
786	void			sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility);
787
788	//--------------------------------------------------------------------
789	// Receive
790	//--------------------------------------------------------------------
791public:
792	static void		processAgentDataUpdate(LLMessageSystem *msg, void **);
793	static void		processAgentGroupDataUpdate(LLMessageSystem *msg, void **);
794	static void		processAgentDropGroup(LLMessageSystem *msg, void **);
795	static void		processScriptControlChange(LLMessageSystem *msg, void **);
796	static void		processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void **user_data);
797	
798/**                    Messaging
799 **                                                                            **
800 *******************************************************************************/
801
802/********************************************************************************
803 **                                                                            **
804 **                    DEBUGGING
805 **/
806
807public:
808	static void		dumpGroupInfo();
809	static void		clearVisualParams(void *);
810	friend std::ostream& operator<<(std::ostream &s, const LLAgent &sphere);
811
812/**                    Debugging
813 **                                                                            **
814 *******************************************************************************/
815
816};
817
818extern LLAgent gAgent;
819
820inline bool operator==(const LLGroupData &a, const LLGroupData &b)
821{
822	return (a.mID == b.mID);
823}
824
825class LLAgentQueryManager
826{
827	friend class LLAgent;
828	friend class LLAgentWearables;
829	
830public:
831	LLAgentQueryManager();
832	virtual ~LLAgentQueryManager();
833	
834	BOOL 			hasNoPendingQueries() const 	{ return getNumPendingQueries() == 0; }
835	S32 			getNumPendingQueries() const 	{ return mNumPendingQueries; }
836private:
837	S32				mNumPendingQueries;
838	S32				mWearablesCacheQueryID;
839	U32				mUpdateSerialNum;
840	S32		    	mActiveCacheQueries[LLVOAvatarDefines::BAKED_NUM_INDICES];
841};
842
843extern LLAgentQueryManager gAgentQueryManager;
844
845#endif