PageRenderTime 34ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

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